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

Commit 3d7303f

Browse files
committed
refactor: simplify getProjectDir helper
1 parent 438d51b commit 3d7303f

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

bin/ns-verify-bundle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const fs = require("fs");
77

88
const { getProjectDir } = require("../projectHelpers");
99

10-
const PROJECT_DIR = getProjectDir({ nestingLvl: 2 });
10+
const PROJECT_DIR = getProjectDir();
1111
const APP_ID = require(path.resolve(PROJECT_DIR, "./package.json")).nativescript.id;
1212
const APP_NAME = APP_ID.substring(APP_ID.lastIndexOf(".") + 1);
1313
const PROJECT_PATHS = {

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { existsSync } = require("fs");
33

44
const { getPackageJson, getProjectDir, isAngular, resolveAndroidAppPath } = require("./projectHelpers");
55

6-
const PROJECT_DIR = getProjectDir({ nestingLvl: 2 });
6+
const PROJECT_DIR = getProjectDir();
77
const APP_DIR = path.join(PROJECT_DIR, "app");
88

99
Object.assign(exports, require('./plugins'));

installer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const helpers = require("./projectHelpers");
55
const projectFilesManager = require("./projectFilesManager");
66
const dependencyManager = require("./dependencyManager");
77

8-
const PROJECT_DIR = helpers.getProjectDir({ nestingLvl: 2 });
8+
const PROJECT_DIR = helpers.getProjectDir();
99
const APP_DIR = path.resolve(PROJECT_DIR, "app");
1010

1111
function install() {

projectHelpers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const getAndroidRuntimeVersion = (projectDir) => {
4444
}
4545
}
4646

47-
const getWebpackConfig = (projectDir, configPath = "webpack.config.js") => {
47+
const getWebpackConfig = (projectDir, env, configPath = "webpack.config.js") => {
4848
const configAbsolutePath = path.resolve(projectDir, configPath);
4949
let config;
5050
try {
@@ -56,7 +56,7 @@ const getWebpackConfig = (projectDir, configPath = "webpack.config.js") => {
5656
);
5757
}
5858
if (typeof config === "function") {
59-
config = config();
59+
config = config(env);
6060
}
6161

6262
if (!config) {
@@ -75,7 +75,7 @@ const writePackageJson = (content, projectDir) => {
7575
const packageJsonPath = getPackageJsonPath(projectDir);
7676
fs.writeFileSync(packageJsonPath, JSON.stringify(content, null, 2))
7777
}
78-
const getProjectDir = ({ nestingLvl } = { nestingLvl: 0 }) => {
78+
const getProjectDir = ({ nestingLvl } = { nestingLvl: 2 }) => {
7979
// INIT_CWD is available since npm 5.4
8080
const initCwd = process.env.INIT_CWD;
8181
const shouldUseInitCwd = (() => {

verify/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { forceUpdateProjectFiles } = require("../projectFilesManager");
66
const { forceUpdateProjectDeps } = require("../dependencyManager");
77

88
const PLUGIN_NAME = "nativescript-dev-webpack";
9-
const PROJECT_DIR = getProjectDir({ nestingLvl: 2 });
9+
const PROJECT_DIR = getProjectDir();
1010

1111
function update({
1212
deps: shouldUpdateDeps,

0 commit comments

Comments
 (0)