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 #27224 is possible
to being backported in a semver-patch way.

PR-URL: #27483
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
  • Loading branch information
BridgeAR authored and targos committed May 5, 2019
1 parent 91b7f5e commit 826fb66
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 826fb66

Please sign in to comment.