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

Commit 9f9512e

Browse files
sis0k0Vasil Chimev
authored and
Vasil Chimev
committed
refactor: support local install with npm 5.4+ (#279)
1 parent a04dee6 commit 9f9512e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

installer.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,25 @@ const projectFilesManager = require("./projectFilesManager");
66
const npmScriptsManager = require("./npmScriptsManager");
77
const dependencyManager = require("./dependencyManager");
88

9-
const PROJECT_DIR = path.dirname(path.dirname(__dirname));
9+
// INIT_CWD is available since npm 5.4
10+
const initCwd = process.env.INIT_CWD;
11+
const shouldUseInitCwd = () => {
12+
if (!initCwd) {
13+
return false;
14+
}
15+
16+
const installedPackage = path.resolve(initCwd, "node_modules", "nativescript-dev-webpack");
17+
if (!fs.existsSync(installedPackage)) {
18+
return false;
19+
}
20+
21+
const stat = fs.lstatSync(installedPackage);
22+
return stat.isSymbolicLink();
23+
};
24+
25+
const PROJECT_DIR = shouldUseInitCwd() ?
26+
initCwd :
27+
path.dirname(path.dirname(__dirname));
1028
const APP_DIR = path.resolve(PROJECT_DIR, "app");
1129

1230
function install() {

0 commit comments

Comments
 (0)