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

Commit

Permalink
feat(ns-bundle): app can be just prepared and bundled now (#126)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sis0k0 authored Apr 20, 2017
1 parent b9430e3 commit b0688b4
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions bin/ns-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const flags = npmArgs.filter(a => a.startsWith("--")).map(a => a.substring(2));
const options = getOptions(flags);

function getTnsArgs(args) {
let other = [
const other = [
"run",
"ns-bundle",
"--android",
Expand All @@ -36,16 +36,20 @@ function escape(arg) {
execute(options);

function execute(options) {
let commands = [
() => runTns(options.command, options.platform),
];
let commands = [];

if (options.bundle) {
commands = [
() => prepare(options.platform),
() => webpack(options.platform),
...commands
];
commands.push(() => clearPlatform(options.platform));
commands.push(() => webpack(options.platform));
}

// If "build-app" or "start-app" is specified,
// the respective command should be run last.
// Otherwise, the app should be just prepared.
if (options.command) {
commands.push(() => runTns(options.command, options.platform));
} else {
commands.shift(() => runTns("prepare", options.platform))
}

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

function prepare(platform) {
function clearPlatform(platform) {
return removePlatform(platform)
.then(() => addPlatform(platform));
}
Expand Down Expand Up @@ -128,8 +132,6 @@ function getCommand(flags) {
return "run";
} else if (flags.includes("build-app")) {
return "build";
} else {
throwError({message: "You must provide either --start-app, or --build-app flag!"});
}
}

Expand Down

0 comments on commit b0688b4

Please sign in to comment.