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

Commit ebe0cf8

Browse files
committed
fix(ns-bundle): parse all '*-app' flags as tns commands
Allows for using --publish-app along with --start-app, --build-app, etc.
1 parent ae40f93 commit ebe0cf8

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

Diff for: bin/ns-bundle

+9-14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ if (!process.env.npm_config_argv) {
1212
throwError({message: "No flags provided."});
1313
}
1414

15+
const escape = arg => `"${arg}"`;
16+
const isTnsCommand = flag => flag.endsWith("--app");
17+
1518
const npmArgs = JSON.parse(process.env.npm_config_argv).original;
1619
const tnsArgs = getTnsArgs(npmArgs).map(escape);
1720
const flags = npmArgs.filter(a => a.startsWith("--")).map(a => a.substring(2));
@@ -23,17 +26,11 @@ function getTnsArgs(args) {
2326
"ns-bundle",
2427
"--android",
2528
"--ios",
26-
"--build-app",
27-
"--start-app",
2829
"--uglify",
2930
"--nobundle",
3031
];
3132

32-
return args.filter(a => !other.includes(a));
33-
}
34-
35-
function escape(arg) {
36-
return `"${arg}"`;
33+
return args.filter(a => !other.includes(a) && !isTnsCommand(a));
3734
}
3835

3936
execute(options);
@@ -179,15 +176,13 @@ function getPlatform(flags) {
179176
}
180177

181178
function getCommand(flags) {
182-
if (flags.includes("start-app") && flags.includes("build-app")) {
183-
throwError({message: "You cannot use both --start-app and --build-app flags!"});
179+
const commands = flags.filter(isTnsCommand);
180+
if (commands.length > 1) {
181+
throwError({message: `You can't use ${commands.join(", ")} together!`});
184182
}
185183

186-
if (flags.includes("start-app")) {
187-
return "run";
188-
} else if (flags.includes("build-app")) {
189-
return "build";
190-
}
184+
// remove '-app' suffix
185+
return commands[0].replace(/-app/, "");
191186
}
192187

193188
function spawnChildProcess(command, ...args) {

0 commit comments

Comments
 (0)