forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process: add NODE_NO_WARNINGS environment variable
This commit adds support for a NODE_NO_WARNINGS environment variable, which duplicates the functionality of the --no-warnings command line flag. Fixes: nodejs#10802 PR-URL: nodejs#10842 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
- Loading branch information
Showing
4 changed files
with
53 additions
and
1 deletion.
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
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,41 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
|
||
if (process.argv[2] === 'child') { | ||
process.emitWarning('foo'); | ||
} else { | ||
function test(env) { | ||
const cmd = `${process.execPath} ${__filename} child`; | ||
|
||
cp.exec(cmd, { env }, common.mustCall((err, stdout, stderr) => { | ||
assert.strictEqual(err, null); | ||
assert.strictEqual(stdout, ''); | ||
|
||
if (env.NODE_NO_WARNINGS === '1') | ||
assert.strictEqual(stderr, ''); | ||
else | ||
assert(/Warning: foo$/.test(stderr.trim())); | ||
})); | ||
} | ||
|
||
test({}); | ||
test(process.env); | ||
test({ NODE_NO_WARNINGS: undefined }); | ||
test({ NODE_NO_WARNINGS: null }); | ||
test({ NODE_NO_WARNINGS: 'foo' }); | ||
test({ NODE_NO_WARNINGS: true }); | ||
test({ NODE_NO_WARNINGS: false }); | ||
test({ NODE_NO_WARNINGS: {} }); | ||
test({ NODE_NO_WARNINGS: [] }); | ||
test({ NODE_NO_WARNINGS: function() {} }); | ||
test({ NODE_NO_WARNINGS: 0 }); | ||
test({ NODE_NO_WARNINGS: -1 }); | ||
test({ NODE_NO_WARNINGS: '0' }); | ||
test({ NODE_NO_WARNINGS: '01' }); | ||
test({ NODE_NO_WARNINGS: '2' }); | ||
// Don't test the number 1 because it will come through as a string in the | ||
// the child process environment. | ||
test({ NODE_NO_WARNINGS: '1' }); | ||
} |