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

Commit afe6208

Browse files
rosen-vladimirovdtopuzov
authored andcommitted
chore: Do not set INIT_CWD on any hook (#493)
Previously the INIT_CWD environment variable was set only in one of the hooks. In a recent PR, we've changed the logic of all `before-*` hooks to set the INIT_CWD environment variable. After some discussions and investigation, we've found that we do not need the INIT_CWD variable. So remove the setting of the variable from all hooks and delete the method that sets it.
1 parent d2bcb52 commit afe6208

6 files changed

+4
-23
lines changed

Diff for: lib/before-cleanApp.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
const { cleanSnapshotArtefacts } = require("../snapshot/android/project-snapshot-generator");
22
const { isAndroid } = require("../projectHelpers");
3-
const { setProcessInitDirectory } = require("./utils");
43

54
module.exports = function (hookArgs) {
65
if (isAndroid(hookArgs.platformInfo.platform)) {
7-
const projectDir = hookArgs.platformInfo.projectData.projectDir;
8-
setProcessInitDirectory(projectDir);
9-
cleanSnapshotArtefacts(projectDir);
6+
cleanSnapshotArtefacts(hookArgs.platformInfo.projectData.projectDir);
107
}
118
}

Diff for: lib/before-prepareJS.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const { runWebpackCompiler } = require("./compiler");
2-
const { setProcessInitDirectory } = require("./utils");
32

43
module.exports = function ($logger, hookArgs) {
54
const env = hookArgs.config.env || {};
@@ -12,9 +11,6 @@ module.exports = function ($logger, hookArgs) {
1211
release: appFilesUpdaterOptions.release,
1312
};
1413

15-
const projectData = hookArgs.config.projectData;
16-
setProcessInitDirectory(projectData.projectDir);
17-
18-
const result = config.bundle && runWebpackCompiler.bind(runWebpackCompiler, config, projectData, $logger, hookArgs);
14+
const result = config.bundle && runWebpackCompiler.bind(runWebpackCompiler, config, hookArgs.config.projectData, $logger, hookArgs);
1915
return result;
2016
}

Diff for: lib/before-shouldPrepare.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
const { join } = require("path");
22
const { readFileSync, existsSync, writeFileSync } = require("fs");
3-
const { setProcessInitDirectory } = require("./utils");
43
const envOptionsCacheFileLocation = join(__dirname, "env.cache.json");
54

65
module.exports = function (hookArgs) {
76
const platformInfo = hookArgs.shouldPrepareInfo && hookArgs.shouldPrepareInfo.platformInfo;
87
if (platformInfo && platformInfo.appFilesUpdaterOptions && platformInfo.appFilesUpdaterOptions.bundle) {
9-
setProcessInitDirectory(platformInfo.projectData.projectDir);
108

119
return (args, originalMethod) => {
1210
return originalMethod(...args).then(originalShouldPrepare => {

Diff for: lib/before-watch.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const { runWebpackCompiler } = require("./compiler");
2-
const { setProcessInitDirectory } = require("./utils");
32

43
module.exports = function ($logger, hookArgs) {
54
if (hookArgs.config) {
@@ -16,9 +15,7 @@ module.exports = function ($logger, hookArgs) {
1615
watch: true
1716
};
1817

19-
const projectData = hookArgs.projectData;
20-
setProcessInitDirectory(projectData.projectDir);
21-
return runWebpackCompiler(config, projectData, $logger, hookArgs);
18+
return runWebpackCompiler(config, hookArgs.projectData, $logger, hookArgs);
2219
}));
2320
}
2421
}

Diff for: lib/before-watchPatterns.js

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const { basename } = require("path");
22
const {
33
buildEnvData,
44
getCompilationContext,
5-
setProcessInitDirectory,
65
} = require("./utils");
76

87
module.exports = function (hookArgs) {
@@ -11,7 +10,6 @@ module.exports = function (hookArgs) {
1110
return;
1211
}
1312

14-
setProcessInitDirectory(hookArgs.projectData.projectDir);
1513
const { platforms } = hookArgs;
1614
const { env } = liveSyncData;
1715
return (args, originalMethod) => {

Diff for: lib/utils.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@ function shouldSnapshot(config) {
4141
return config.bundle && config.release && platformSupportsSnapshot && osSupportsSnapshot;
4242
}
4343

44-
function setProcessInitDirectory(dir) {
45-
process.env.INIT_CWD = dir;
46-
}
47-
4844
module.exports = {
4945
buildEnvData,
5046
getCompilationContext,
51-
shouldSnapshot,
52-
setProcessInitDirectory,
47+
shouldSnapshot
5348
};

0 commit comments

Comments
 (0)