child_process: copy spawnSync() cwd option to proper buffer
The spawnSync() cwd option was being copied to the incorrect location. This commit copies to the correct location. Closes #7824 Signed-off-by: Fedor Indutny <fedor@indutny.com>
This commit is contained in:
parent
9452ea2ef5
commit
c4e5fde362
@ -726,7 +726,7 @@ int SyncProcessRunner::ParseOptions(Local<Value> js_value) {
|
|||||||
|
|
||||||
Local<Value> js_cwd = js_options->Get(env()->cwd_string());
|
Local<Value> js_cwd = js_options->Get(env()->cwd_string());
|
||||||
if (IsSet(js_cwd)) {
|
if (IsSet(js_cwd)) {
|
||||||
r = CopyJsString(js_cwd, &uv_process_options_.cwd);
|
r = CopyJsString(js_cwd, &cwd_buffer_);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
uv_process_options_.cwd = cwd_buffer_;
|
uv_process_options_.cwd = cwd_buffer_;
|
||||||
|
@ -80,3 +80,19 @@ assert.deepEqual(ret, msgBuf);
|
|||||||
ret = execFileSync(process.execPath, args, { encoding: 'utf8' });
|
ret = execFileSync(process.execPath, args, { encoding: 'utf8' });
|
||||||
|
|
||||||
assert.strictEqual(ret, msg + '\n', 'execFileSync encoding result should match');
|
assert.strictEqual(ret, msg + '\n', 'execFileSync encoding result should match');
|
||||||
|
|
||||||
|
// Verify that the cwd option works - GH #7824
|
||||||
|
(function() {
|
||||||
|
var response;
|
||||||
|
var cwd;
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
cwd = 'c:\\';
|
||||||
|
response = execSync('echo %cd%', {cwd: cwd});
|
||||||
|
} else {
|
||||||
|
cwd = '/';
|
||||||
|
response = execSync('pwd', {cwd: cwd});
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.strictEqual(response.toString().trim(), cwd);
|
||||||
|
})();
|
||||||
|
@ -46,3 +46,19 @@ assert.strictEqual(stop[0], 1, 'sleep should not take longer or less than 1 seco
|
|||||||
// Error test when command does not exist
|
// Error test when command does not exist
|
||||||
var ret_err = spawnSync('command_does_not_exist');
|
var ret_err = spawnSync('command_does_not_exist');
|
||||||
assert.strictEqual(ret_err.error.code, 'ENOENT');
|
assert.strictEqual(ret_err.error.code, 'ENOENT');
|
||||||
|
|
||||||
|
// Verify that the cwd option works - GH #7824
|
||||||
|
(function() {
|
||||||
|
var response;
|
||||||
|
var cwd;
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
cwd = 'c:\\';
|
||||||
|
response = spawnSync('cmd.exe', ['/c', 'cd'], {cwd: cwd});
|
||||||
|
} else {
|
||||||
|
cwd = '/';
|
||||||
|
response = spawnSync('pwd', [], {cwd: cwd});
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.strictEqual(response.stdout.toString().trim(), cwd);
|
||||||
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user