Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"dependencies": {
"global-modules-path": "2.0.0",
"minimatch": "3.0.4",
"nativescript-hook": "0.2.2",
"nativescript-hook": "0.2.3",
"proxy-lib": "0.4.0",
"request": "2.83.0",
"schema-utils": "0.4.3",
Expand Down
10 changes: 6 additions & 4 deletions postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
const { dirname } = require("path");
const hook = require("nativescript-hook")(__dirname);

if (hook.findProjectDir() === __dirname) {
// We are installing dev dependencies for the nativescript-dev-webpack plugin.
console.log("Skipping postinstall artifacts! We assumed the nativescript-dev-webpack is installing devDependencies");
} else {
const { getProjectDir } = require("./projectHelpers");

if (getProjectDir()) {
hook.postinstall();
const installer = require("./installer");
installer.install();
} else {
// We are installing dev dependencies for the nativescript-dev-webpack plugin.
console.log("Skipping postinstall artifacts! We assumed the nativescript-dev-webpack is installing devDependencies");
}
25 changes: 2 additions & 23 deletions projectHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require("path");
const fs = require("fs");
const semver = require("semver");
const { EOL } = require("os");
const hook = require("nativescript-hook")(__dirname);

const {
PROJECT_DATA_GETTERS,
Expand Down Expand Up @@ -85,29 +86,7 @@ const writePackageJson = (content, projectDir) => {
const packageJsonPath = getPackageJsonPath(projectDir);
fs.writeFileSync(packageJsonPath, JSON.stringify(content, null, 2))
}
const getProjectDir = ({ nestingLvl } = { nestingLvl: 2 }) => {
// 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();
})();

return shouldUseInitCwd ?
initCwd :
Array
.from(Array(nestingLvl))
.reduce(dir => path.dirname(dir), __dirname);
};
const getProjectDir = hook.findProjectDir;

const toReleaseVersion = version =>
version.replace(/-.*/, "");
Expand Down