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

feat(ns-bundle): app can be just prepared and bundled now #126

Merged
merged 1 commit into from
Apr 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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