-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-7xcx-6wjh-7xp2
- Uses `execFile` with arguments instead of `exec` where possible. - See GHSL-2020-111 Co-authored-by: Benjamin E. Coe <bencoe@google.com>
- Loading branch information
1 parent
a0f0e81
commit 871201f
Showing
4 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { execFile } = require('child_process') | ||
const printError = require('./print-error') | ||
|
||
module.exports = function (args, cmd, cmdArgs) { | ||
if (args.dryRun) return Promise.resolve() | ||
return new Promise((resolve, reject) => { | ||
// Exec given cmd and handle possible errors | ||
execFile(cmd, cmdArgs, function (err, stdout, stderr) { | ||
// If exec returns content in stderr, but no error, print it as a warning | ||
// If exec returns an error, print it and exit with return code 1 | ||
if (err) { | ||
printError(args, stderr || err.message) | ||
return reject(err) | ||
} else if (stderr) { | ||
printError(args, stderr, { level: 'warn', color: 'yellow' }) | ||
} | ||
return resolve(stdout) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters