-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
sea: implement execArgvExtension #59560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nodejs-github-bot
merged 1 commit into
nodejs:main
from
joyeecheung:sea-exec-argv-extension
Aug 25, 2025
+372
−7
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,14 @@ | ||
const assert = require('assert'); | ||
|
||
console.log('process.argv:', JSON.stringify(process.argv)); | ||
console.log('process.execArgv:', JSON.stringify(process.execArgv)); | ||
|
||
// Should have execArgv from SEA config + CLI --node-options | ||
assert.deepStrictEqual(process.execArgv, ['--no-warnings', '--max-old-space-size=1024']); | ||
|
||
assert.deepStrictEqual(process.argv.slice(2), [ | ||
'user-arg1', | ||
'user-arg2' | ||
]); | ||
|
||
console.log('execArgvExtension cli test passed'); |
This file contains hidden or 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,19 @@ | ||
const assert = require('assert'); | ||
|
||
process.emitWarning('This warning should not be shown in the output', 'TestWarning'); | ||
|
||
console.log('process.argv:', JSON.stringify(process.argv)); | ||
console.log('process.execArgv:', JSON.stringify(process.execArgv)); | ||
|
||
// Should have execArgv from SEA config. | ||
// Note that flags from NODE_OPTIONS are not included in process.execArgv no matter it's | ||
// an SEA or not, but we can test whether it works by checking that the warning emitted | ||
// above was silenced. | ||
assert.deepStrictEqual(process.execArgv, ['--no-warnings']); | ||
|
||
assert.deepStrictEqual(process.argv.slice(2), [ | ||
'user-arg1', | ||
'user-arg2' | ||
]); | ||
|
||
console.log('execArgvExtension env test passed'); |
This file contains hidden or 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,14 @@ | ||
const assert = require('assert'); | ||
|
||
console.log('process.argv:', JSON.stringify(process.argv)); | ||
console.log('process.execArgv:', JSON.stringify(process.execArgv)); | ||
|
||
// Should only have execArgv from SEA config, no NODE_OPTIONS | ||
assert.deepStrictEqual(process.execArgv, ['--no-warnings']); | ||
|
||
assert.deepStrictEqual(process.argv.slice(2), [ | ||
'user-arg1', | ||
'user-arg2' | ||
]); | ||
|
||
console.log('execArgvExtension none test passed'); |
63 changes: 63 additions & 0 deletions
63
test/sequential/test-single-executable-application-exec-argv-extension-cli.js
This file contains hidden or 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,63 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
|
||
const { | ||
generateSEA, | ||
skipIfSingleExecutableIsNotSupported, | ||
} = require('../common/sea'); | ||
|
||
skipIfSingleExecutableIsNotSupported(); | ||
|
||
// This tests the execArgvExtension "cli" mode in single executable applications. | ||
|
||
const fixtures = require('../common/fixtures'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const { copyFileSync, writeFileSync, existsSync } = require('fs'); | ||
const { spawnSyncAndAssert, spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
const { join } = require('path'); | ||
const assert = require('assert'); | ||
|
||
const configFile = tmpdir.resolve('sea-config.json'); | ||
const seaPrepBlob = tmpdir.resolve('sea-prep.blob'); | ||
const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'sea'); | ||
|
||
tmpdir.refresh(); | ||
|
||
// Copy test fixture to working directory | ||
copyFileSync(fixtures.path('sea-exec-argv-extension-cli.js'), tmpdir.resolve('sea.js')); | ||
|
||
writeFileSync(configFile, ` | ||
{ | ||
"main": "sea.js", | ||
"output": "sea-prep.blob", | ||
"disableExperimentalSEAWarning": true, | ||
"execArgv": ["--no-warnings"], | ||
"execArgvExtension": "cli" | ||
} | ||
`); | ||
|
||
spawnSyncAndExitWithoutError( | ||
process.execPath, | ||
['--experimental-sea-config', 'sea-config.json'], | ||
{ cwd: tmpdir.path }); | ||
|
||
assert(existsSync(seaPrepBlob)); | ||
|
||
generateSEA(outputFile, process.execPath, seaPrepBlob); | ||
|
||
// Test that --node-options works with execArgvExtension: "cli" | ||
spawnSyncAndAssert( | ||
outputFile, | ||
['--node-options=--max-old-space-size=1024', 'user-arg1', 'user-arg2'], | ||
{ | ||
env: { | ||
...process.env, | ||
NODE_OPTIONS: '--max-old-space-size=2048', // Should be ignored | ||
COMMON_DIRECTORY: join(__dirname, '..', 'common'), | ||
NODE_DEBUG_NATIVE: 'SEA', | ||
} | ||
}, | ||
{ | ||
stdout: /execArgvExtension cli test passed/ | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: it might be good to define "cli" in here very briefly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean defining the word "cli" as "command line interface"? I feel that for the target audience of this part of the documentation, that would be a bit superfluous - it seems unlikely that someone who is packaging an an application as a CLI SEA does not know what "cli" means.