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

fix(ns-bundle): respect platform version from app package.json #138

Merged
merged 2 commits into from
May 3, 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
17 changes: 13 additions & 4 deletions bin/ns-bundle
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/usr/bin/env node

const spawn = require("child_process").spawn;
const path = require("path");
const resolve = require("path").resolve;

const PROJECT_DIR = path.resolve(__dirname, "../../../");
const getPackageJson = require("../projectHelpers").getPackageJson;

const PROJECT_DIR = resolve(__dirname, "../../../");
const packageJson = getPackageJson(PROJECT_DIR);

if (!process.env.npm_config_argv) {
throwError({message: "No flags provided."});
Expand All @@ -14,6 +17,11 @@ const tnsArgs = getTnsArgs(npmArgs).map(escape);
const flags = npmArgs.filter(a => a.startsWith("--")).map(a => a.substring(2));
const options = getOptions(flags);

let platformVersion;
try {
platformVersion = packageJson.nativescript[`tns-${options.platform}`].version;
} catch(e) {}

function getTnsArgs(args) {
const other = [
"run",
Expand Down Expand Up @@ -82,9 +90,10 @@ function removePlatform(platform) {

function addPlatform(platform) {
return new Promise(function (resolve, reject) {
console.log(`Adding platform ${platform}...`);
const platformToAdd = platformVersion ? `${platform}@${platformVersion}` : platform;
console.log(`Adding platform ${platformToAdd}...`);

spawnChildProcess(false, "tns", "platform", "add", platform)
spawnChildProcess(false, "tns", "platform", "add", platformToAdd)
.then(resolve)
.catch(resolve);
});
Expand Down