Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/api/v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
// process.env and process.argv are refreshed during snapshot
// deserialization.
const lang = process.env.BOOK_LANG || 'en_US';
const book = process.argv[1];
const book = process.argv[2];
const name = `${book}.${lang}.txt`;
console.log(shelf.storage.get(name));
}, shelf);
Expand Down
6 changes: 3 additions & 3 deletions lib/internal/v8/startup_snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ function setDeserializeMainFunction(callback, data) {
markBootstrapComplete,
} = require('internal/process/pre_execution');

// This should be in sync with run_main_module.js until we make that
// a built-in main function.
// TODO(joyeecheung): make a copy of argv[0] and insert it as argv[1].
prepareMainThreadExecution(false);
// Like SEA (FixupArgsForSEA), insert argv[0] at argv[1] so that user
// args begin at argv[2], consistent with run_main_module.js.
process.argv.splice(1, 0, process.argv[0]);
markBootstrapComplete();
callback(data);
});
Expand Down
2 changes: 1 addition & 1 deletion test/embedding/test-embedding-snapshot-as-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spawnSyncAndAssert(
stdout(output) {
assert.deepStrictEqual(JSON.parse(output), {
originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs],
currentArgv: [embedtest, ...runSnapshotExecArgs],
currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs],
});
return true;
},
Expand Down
2 changes: 1 addition & 1 deletion test/embedding/test-embedding-snapshot-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spawnSyncAndAssert(
stdout(output) {
assert.deepStrictEqual(JSON.parse(output), {
originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs],
currentArgv: [embedtest, ...runSnapshotExecArgs],
currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs],
});
return true;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spawnSyncAndAssert(
stdout(output) {
assert.deepStrictEqual(JSON.parse(output), {
originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs],
currentArgv: [embedtest, ...runSnapshotExecArgs],
currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs],
});
return true;
},
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/snapshot/typescript-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const v8 = require('v8');
const assert = require('assert');

v8.startupSnapshot.setDeserializeMainFunction(( { ts }) => {
const input = process.argv[1];
const output = process.argv[2];
const input = process.argv[2];
const output = process.argv[3];
console.error(`Compiling ${input} to ${output}`);
assert(input);
assert(output);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/snapshot/v8-startup-snapshot-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
// process.env and process.argv are refreshed during snapshot
// deserialization.
const lang = process.env.BOOK_LANG || 'en_US';
const book = process.argv[1];
const book = process.argv[2];
const name = `${book}.${lang}.txt`;
console.error('Reading', name);
console.log(shelf.storage.get(name).toString());
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-snapshot-argv1.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ require('v8').startupSnapshot.setDeserializeMainFunction(() => {

const stdout = JSON.parse(child.stdout.toString().trim());
assert.deepStrictEqual(stdout, [
process.execPath,
process.execPath,
'argv1',
'argv2',
Expand Down
Loading