Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 6609370

Browse files
authored
fix(ns-bundle): use remove/add platform instead of clean-app (#116)
Leaving old build files in the platform folders caused several issues. fixes 75, fixes 112
1 parent 9fde66f commit 6609370

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

‎bin/ns-bundle‎

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function execute(options) {
3737
];
3838

3939
if (options.bundle) {
40-
commands.unshift(() => webpack(options.platform));
40+
commands = [
41+
() => prepare(options.platform),
42+
() => webpack(options.platform),
43+
...commands
44+
];
4145
}
4246

4347
return commands.reduce((current, next) => current.then(next), Promise.resolve());
@@ -47,17 +51,42 @@ function webpack(platform) {
4751
return new Promise(function (resolve, reject) {
4852
console.log(`Running webpack for ${platform}...`);
4953

50-
spawnChildProcess("tns", "clean-app", platform)
51-
.then(() => spawnChildProcess("webpack", `--config=webpack.${platform}.js`, "--progress"))
54+
spawnChildProcess(true, "webpack", `--config=webpack.${platform}.js`, "--progress")
5255
.then(resolve)
5356
.catch(throwError);
5457
});
5558
}
5659

60+
function prepare(platform) {
61+
return removePlatform(platform)
62+
.then(() => addPlatform(platform));
63+
}
64+
65+
function removePlatform(platform) {
66+
return new Promise(function (resolve, reject) {
67+
console.log(`Removing platform ${platform}...`);
68+
69+
spawnChildProcess(false, "tns", "platform", "remove", platform)
70+
.then(resolve)
71+
.catch(resolve);
72+
});
73+
}
74+
75+
function addPlatform(platform) {
76+
return new Promise(function (resolve, reject) {
77+
console.log(`Adding platform ${platform}...`);
78+
79+
spawnChildProcess(false, "tns", "platform", "add", platform)
80+
.then(resolve)
81+
.catch(resolve);
82+
});
83+
}
84+
5785
function runTns(command, platform) {
58-
console.log(`Running tns ${command}...`);
5986
return new Promise((resolve, reject) => {
60-
spawnChildProcess("tns", command, platform, "--bundle", "--disable-npm-install", ...tnsArgs)
87+
console.log(`Running tns ${command}...`);
88+
89+
spawnChildProcess(true, "tns", command, platform, "--bundle", "--disable-npm-install", ...tnsArgs)
6190
.then(resolve)
6291
.catch(throwError);
6392
});
@@ -100,9 +129,11 @@ function getCommand(flags) {
100129
}
101130
}
102131

103-
function spawnChildProcess(command, ...args) {
132+
function spawnChildProcess(shouldPrintOutput, command, ...args) {
133+
const stdio = shouldPrintOutput ? "inherit" : "ignore";
134+
104135
return new Promise((resolve, reject) => {
105-
const childProcess = spawn(command, args, { stdio: "inherit", pwd: PROJECT_DIR, shell: true });
136+
const childProcess = spawn(command, args, { stdio, pwd: PROJECT_DIR, shell: true });
106137

107138
childProcess.on("close", (code) => {
108139
if (code === 0) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /