Skip to content

Commit

Permalink
process: compatibility patch to backport 1d022e8
Browse files Browse the repository at this point in the history
This makes sure nodejs#27224 is possible
to being backported in a semver-patch way.
  • Loading branch information
BridgeAR committed Apr 29, 2019
1 parent 3bafdcf commit bbc38b7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
5 changes: 0 additions & 5 deletions lib/internal/main/worker_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,9 @@ port.on('message', (message) => {
// The counter is only passed to the workers created by the main thread, not
// to workers created by other workers.
let cachedCwd = '';
let lastCounter = -1;
const originalCwd = process.cwd;

process.cwd = function() {
const currentCounter = Atomics.load(cwdCounter, 0);
if (currentCounter === lastCounter)
return cachedCwd;
lastCounter = currentCounter;
cachedCwd = originalCwd();
return cachedCwd;
};
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/process/main_thread_only.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ function wrapProcessMethods(binding) {
}

function cwd() {
if (cachedCwd === '')
cachedCwd = binding.cwd();
cachedCwd = binding.cwd();
return cachedCwd;
}

Expand Down

0 comments on commit bbc38b7

Please sign in to comment.