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

Commit

Permalink
fix(ns-bundle): parse all '*-app' flags as tns commands (#166)
Browse files Browse the repository at this point in the history
Allows for using --publish-app along with --start-app, --build-app, etc.
  • Loading branch information
sis0k0 authored May 30, 2017
1 parent ae40f93 commit 8e7a1b3
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions bin/ns-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ if (!process.env.npm_config_argv) {
throwError({message: "No flags provided."});
}

const escape = arg => `"${arg}"`;
const isTnsCommand = flag => flag.endsWith("-app");

const npmArgs = JSON.parse(process.env.npm_config_argv).original;
const tnsArgs = getTnsArgs(npmArgs).map(escape);
const flags = npmArgs.filter(a => a.startsWith("--")).map(a => a.substring(2));
Expand All @@ -23,17 +26,11 @@ function getTnsArgs(args) {
"ns-bundle",
"--android",
"--ios",
"--build-app",
"--start-app",
"--uglify",
"--nobundle",
];

return args.filter(a => !other.includes(a));
}

function escape(arg) {
return `"${arg}"`;
return args.filter(a => !other.includes(a) && !isTnsCommand(a));
}

execute(options);
Expand Down Expand Up @@ -179,15 +176,12 @@ function getPlatform(flags) {
}

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

if (flags.includes("start-app")) {
return "run";
} else if (flags.includes("build-app")) {
return "build";
}
return commands[0].replace(/-app/, "");
}

function spawnChildProcess(command, ...args) {
Expand Down

0 comments on commit 8e7a1b3

Please sign in to comment.