Skip to content

Commit 77fed31

Browse files
authored
fix: resolve compiled output from dist in bin and postinstall (#6095)
1 parent cb3fb8d commit 77fed31

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

bin/tns

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
"use strict";
44
var path = require("path"),
5-
pathToLib = path.join(__dirname, "..", "lib"),
5+
fs = require("fs"),
6+
// In the published package dist/ is the root, so lib/ already sits next to
7+
// bin/. In a source checkout lib/ holds only TypeScript and the compiled
8+
// output lives under dist/.
9+
distLib = path.join(__dirname, "..", "dist", "lib"),
10+
pathToLib = fs.existsSync(distLib)
11+
? distLib
12+
: path.join(__dirname, "..", "lib"),
613
pathToCommon = path.join(pathToLib, "common");
714

815
require(path.join(pathToCommon, "verify-node-version")).verifyNodeVersion();

postinstall.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
var child_process = require("child_process");
44
var path = require("path");
5-
var constants = require(path.join(__dirname, "lib", "constants"));
5+
var fs = require("fs");
6+
// In the published package dist/ is the root; in a source checkout the compiled
7+
// output lives under dist/ while lib/ holds only TypeScript.
8+
var distLib = path.join(__dirname, "dist", "lib");
9+
var pathToLib = fs.existsSync(distLib) ? distLib : path.join(__dirname, "lib");
10+
var constants = require(path.join(pathToLib, "constants"));
611
var commandArgs = [path.join(__dirname, "bin", "tns"), constants.POST_INSTALL_COMMAND_NAME];
7-
var helpers = require(path.join(__dirname, "lib", "common", "helpers"));
12+
var helpers = require(path.join(pathToLib, "common", "helpers"));
813
if (helpers.isInstallingNativeScriptGlobally()) {
914
child_process.spawn(process.argv[0], commandArgs, { stdio: "inherit" });
1015
}

0 commit comments

Comments
 (0)