Skip to content

Commit 9ba5092

Browse files
committed
fix: resolve compiled output from dist in bin and postinstall
Both resolve into lib/ relative to their own location, which stopped working when the build moved output to dist/: lib/ now holds only TypeScript, so running ./bin/tns or postinstall.js from a checkout fails with MODULE_NOT_FOUND. The published package is unaffected, since dist/ is its root and lib/ already sits next to bin/ there. Both now prefer dist/lib when it exists and fall back otherwise, which covers the checkout and the package without either needing to know which it is. The other bin entries delegate to ./tns, so they are fixed with it. npm install in a checkout runs postinstall and would hit the same failure - masked only because npm run setup passes --ignore-scripts.
1 parent cb3fb8d commit 9ba5092

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)