Skip to content

Commit

Permalink
Fix writeFileSync regression in Node 21
Browse files Browse the repository at this point in the history
By adding a [`w` flag to the write
call](nodejs/node#50989). Also made a test
more forgiving so it passes on systems that have non-standard `bash` and
`sh` binary paths.
  • Loading branch information
skeet70 committed Dec 4, 2023
1 parent 78ed036 commit c04ed17
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function execSync(cmd, opts, pipe) {
fs.writeFileSync(filePath, data, {
encoding: 'utf8',
mode: parseInt('600', 8),
flag: 'w',
});
}
writeFileLockedDown(stdoutFile, '');
Expand Down
4 changes: 2 additions & 2 deletions test/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ test('set shell option (TODO: add tests for Windows)', t => {
t.is(result.stdout, '/bin/sh\n'); // sh by default
const bashPath = shell.which('bash').trim();
if (bashPath) {
result = shell.exec('echo $0', { shell: '/bin/bash' });
result = shell.exec('echo $0', { shell: bashPath });
t.falsy(shell.error());
t.is(result.code, 0);
t.is(result.stdout, '/bin/bash\n');
t.is(result.stdout, `${bashPath}\n`);
}
});
});
Expand Down

0 comments on commit c04ed17

Please sign in to comment.