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

Commit 839ce93

Browse files
authored
fix(ns-bundle): respect platform version from app package.json (#138)
* fix(ns-bundle): respect platform version from app package.json * fix: typo in bundle script
1 parent 70b3a31 commit 839ce93

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Diff for: bin/ns-bundle

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/usr/bin/env node
22

33
const spawn = require("child_process").spawn;
4-
const path = require("path");
4+
const resolve = require("path").resolve;
55

6-
const PROJECT_DIR = path.resolve(__dirname, "../../../");
6+
const getPackageJson = require("../projectHelpers").getPackageJson;
7+
8+
const PROJECT_DIR = resolve(__dirname, "../../../");
9+
const packageJson = getPackageJson(PROJECT_DIR);
710

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

20+
let platformVersion;
21+
try {
22+
platformVersion = packageJson.nativescript[`tns-${options.platform}`].version;
23+
} catch(e) {}
24+
1725
function getTnsArgs(args) {
1826
const other = [
1927
"run",
@@ -82,9 +90,10 @@ function removePlatform(platform) {
8290

8391
function addPlatform(platform) {
8492
return new Promise(function (resolve, reject) {
85-
console.log(`Adding platform ${platform}...`);
93+
const platformToAdd = platformVersion ? `${platform}@${platformVersion}` : platform;
94+
console.log(`Adding platform ${platformToAdd}...`);
8695

87-
spawnChildProcess(false, "tns", "platform", "add", platform)
96+
spawnChildProcess(false, "tns", "platform", "add", platformToAdd)
8897
.then(resolve)
8998
.catch(resolve);
9099
});

0 commit comments

Comments
 (0)