Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit df038a8

Browse files
committed
feat(ns-bundle): app can be just prepared and bundled now
If you don't pass `--start-app` or `--build-app` to ns-bundle, the project will be only prepared and bundled now. This can be used with the following command: `npm run ns-bundle --android/ios` Related to NativeScript/nativescript-cli#2716
1 parent b9430e3 commit df038a8

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

bin/ns-bundle

+14-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const flags = npmArgs.filter(a => a.startsWith("--")).map(a => a.substring(2));
1515
const options = getOptions(flags);
1616

1717
function getTnsArgs(args) {
18-
let other = [
18+
const other = [
1919
"run",
2020
"ns-bundle",
2121
"--android",
@@ -36,16 +36,20 @@ function escape(arg) {
3636
execute(options);
3737

3838
function execute(options) {
39-
let commands = [
40-
() => runTns(options.command, options.platform),
41-
];
39+
let commands = [];
4240

4341
if (options.bundle) {
44-
commands = [
45-
() => prepare(options.platform),
46-
() => webpack(options.platform),
47-
...commands
48-
];
42+
commands.push(() => clearPlatform(options.platform));
43+
commands.push(() => webpack(options.platform));
44+
}
45+
46+
// If "build-app" or "start-app" is specified,
47+
// the respective command should be run last.
48+
// Otherwise, the app should be just prepared.
49+
if (options.command) {
50+
commands.push(() => runTns(options.command, options.platform));
51+
} else {
52+
commands.shift(() => runTns("prepare", options.platform))
4953
}
5054

5155
return commands.reduce((current, next) => current.then(next), Promise.resolve());
@@ -61,7 +65,7 @@ function webpack(platform) {
6165
});
6266
}
6367

64-
function prepare(platform) {
68+
function clearPlatform(platform) {
6569
return removePlatform(platform)
6670
.then(() => addPlatform(platform));
6771
}
@@ -128,8 +132,6 @@ function getCommand(flags) {
128132
return "run";
129133
} else if (flags.includes("build-app")) {
130134
return "build";
131-
} else {
132-
throwError({message: "You must provide either --start-app, or --build-app flag!"});
133135
}
134136
}
135137

0 commit comments

Comments
 (0)