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

refactor: support local install with npm 5.4+ #279

Merged
merged 1 commit into from
Oct 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
20 changes: 19 additions & 1 deletion installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,25 @@ const projectFilesManager = require("./projectFilesManager");
const npmScriptsManager = require("./npmScriptsManager");
const dependencyManager = require("./dependencyManager");

const PROJECT_DIR = path.dirname(path.dirname(__dirname));
// INIT_CWD is available since npm 5.4
const initCwd = process.env.INIT_CWD;
const shouldUseInitCwd = () => {
if (!initCwd) {
return false;
}

const installedPackage = path.resolve(initCwd, "node_modules", "nativescript-dev-webpack");
if (!fs.existsSync(installedPackage)) {
return false;
}

const stat = fs.lstatSync(installedPackage);
return stat.isSymbolicLink();
};

const PROJECT_DIR = shouldUseInitCwd() ?
initCwd :
path.dirname(path.dirname(__dirname));
const APP_DIR = path.resolve(PROJECT_DIR, "app");

function install() {
Expand Down