Skip to content

Commit

Permalink
Add nodeNoWarningsFlags constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Dec 13, 2024
1 parent 49d24d4 commit 2301a2e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions registry/lib/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ declare const constantsModule: {
readonly kInternalsSymbol: typeof kInternalsSymbol
readonly lifecycleScriptNames: ReadonlySet<string>
readonly maintainedNodeVersions: MaintainedNodeVersions
readonly nodeNoWarningsFlags:
| ReadonlyArray<['--disable-warning', 'ExperimentalWarning']>
| ReadonlyArray<['--no-warnings']>
readonly npmExecPath: string
readonly packageExtensions: ReadonlyArray<[string, object]>
readonly packumentCache: Map<unknown, unknown>
Expand Down
9 changes: 9 additions & 0 deletions registry/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ const lazyMaintainedNodeVersions = () => {
)
}

const lazyNodeNoWarningsFlags = () =>
Object.freeze(
constants.SUPPORTS_NODE_DISABLE_WARNING_FLAG
? ['--disable-warning', 'ExperimentalWarning']
: ['--no-warnings']
)

const lazyNpmExecPath = () => whichSync('npm')

const copyLeftLicenses = new Set([
Expand Down Expand Up @@ -573,6 +580,7 @@ const constants = createConstantsObject(
ignoreGlobs,
lifecycleScriptNames,
maintainedNodeVersions: undefined,
nodeNoWarningsFlags: undefined,
npmExecPath: undefined,
packageExtensions,
packumentCache,
Expand All @@ -591,6 +599,7 @@ const constants = createConstantsObject(
SUPPORTS_NODE_REQUIRE_MODULE: LAZY_SUPPORTS_NODE_REQUIRE_MODULE,
SUPPORTS_NODE_RUN: LAZY_SUPPORTS_NODE_RUN,
maintainedNodeVersions: lazyMaintainedNodeVersions,
nodeNoWarningsFlags: lazyNodeNoWarningsFlags,
npmExecPath: lazyNpmExecPath
}
}
Expand Down
17 changes: 10 additions & 7 deletions registry/lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ async function runBin(binPath, args, options) {
[
...(WIN_32
? []
: // Lazily access constants.SUPPORTS_NODE_DISABLE_WARNING_FLAG.
constants.SUPPORTS_NODE_DISABLE_WARNING_FLAG
? ['--disable-warning', 'ExperimentalWarning', binPath]
: ['--no-warnings', binPath]),
: [
// Lazily access constants.nodeNoWarningsFlags.
...constants.nodeNoWarningsFlags,
binPath
]),
...args
],
{
Expand All @@ -47,9 +48,11 @@ async function runScript(scriptName, args, options) {
cmd,
[
...(useNodeRun
? constants.SUPPORTS_NODE_DISABLE_WARNING_FLAG
? ['--disable-warning', 'ExperimentalWarning', '--run']
: ['--no-warnings', '--run']
? [
// Lazily access constants.nodeNoWarningsFlags.
...constants.nodeNoWarningsFlags,
'--run'
]
: ['run']),
scriptName,
...args
Expand Down

0 comments on commit 2301a2e

Please sign in to comment.