File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -745,6 +745,8 @@ changes:
745745 * ` exec ` {string} File path to worker file. ** Default:** ` process.argv[1] `
746746 * ` args ` {Array} String arguments passed to worker.
747747 ** Default:** ` process.argv.slice(2) `
748+ * ` cwd ` {string} Current working directory of the worker process. ** Default:**
749+ ` undefined ` (inherits from parent process)
748750 * ` silent ` {boolean} Whether or not to send output to parent's stdio.
749751 ** Default:** ` false `
750752 * ` stdio ` {Array} Configures the stdio of forked processes. Because the
Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ function createWorkerProcess(id, env) {
129129 }
130130
131131 return fork ( cluster . settings . exec , cluster . settings . args , {
132+ cwd : cluster . settings . cwd ,
132133 env : workerEnv ,
133134 silent : cluster . settings . silent ,
134135 windowsHide : cluster . settings . windowsHide ,
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
4+ const cluster = require ( 'cluster' ) ;
5+
6+ if ( cluster . isMaster ) {
7+ common . refreshTmpDir ( ) ;
8+
9+ assert . strictEqual ( cluster . settings . cwd , undefined ) ;
10+ cluster . fork ( ) . on ( 'message' , common . mustCall ( ( msg ) => {
11+ assert . strictEqual ( msg , process . cwd ( ) ) ;
12+ } ) ) ;
13+
14+ cluster . setupMaster ( { cwd : common . tmpDir } ) ;
15+ assert . strictEqual ( cluster . settings . cwd , common . tmpDir ) ;
16+ cluster . fork ( ) . on ( 'message' , common . mustCall ( ( msg ) => {
17+ assert . strictEqual ( msg , common . tmpDir ) ;
18+ } ) ) ;
19+ } else {
20+ process . send ( process . cwd ( ) ) ;
21+ process . disconnect ( ) ;
22+ }
You can’t perform that action at this time.
0 commit comments