GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: insert argv[0] at argv[1] in setDeserializeMainFunction · nodejs/node@19c46ab

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • v8.md
  • lib/internal/v8
    • startup_snapshot.js
  • test
    • embedding
      • test-embedding-snapshot-as-file.js
      • test-embedding-snapshot-basic.js
      • test-embedding-snapshot-without-code-cache.js
    • fixtures/snapshot
      • typescript-main.js
      • v8-startup-snapshot-api.js
    • parallel
      • test-snapshot-argv1.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/v8.md‎

Copy file name to clipboardExpand all lines: doc/api/v8.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
13551355
// process.env and process.argv are refreshed during snapshot
13561356
// deserialization.
13571357
const lang = process.env.BOOK_LANG || 'en_US';
1358-
const book = process.argv[1];
1358+
const book = process.argv[2];
13591359
const name = `${book}.${lang}.txt`;
13601360
console.log(shelf.storage.get(name));
13611361
}, shelf);
Collapse file

‎lib/internal/v8/startup_snapshot.js‎

Copy file name to clipboardExpand all lines: lib/internal/v8/startup_snapshot.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ function setDeserializeMainFunction(callback, data) {
109109
markBootstrapComplete,
110110
} = require('internal/process/pre_execution');
111111

112-
// This should be in sync with run_main_module.js until we make that
113-
// a built-in main function.
114-
// TODO(joyeecheung): make a copy of argv[0] and insert it as argv[1].
115112
prepareMainThreadExecution(false);
113+
// Like SEA (FixupArgsForSEA), insert argv[0] at argv[1] so that user
114+
// args begin at argv[2], consistent with run_main_module.js.
115+
process.argv.splice(1, 0, process.argv[0]);
116116
markBootstrapComplete();
117117
callback(data);
118118
});
Collapse file

‎test/embedding/test-embedding-snapshot-as-file.js‎

Copy file name to clipboardExpand all lines: test/embedding/test-embedding-snapshot-as-file.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ spawnSyncAndAssert(
4343
stdout(output) {
4444
assert.deepStrictEqual(JSON.parse(output), {
4545
originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs],
46-
currentArgv: [embedtest, ...runSnapshotExecArgs],
46+
currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs],
4747
});
4848
return true;
4949
},
Collapse file

‎test/embedding/test-embedding-snapshot-basic.js‎

Copy file name to clipboardExpand all lines: test/embedding/test-embedding-snapshot-basic.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ spawnSyncAndAssert(
4343
stdout(output) {
4444
assert.deepStrictEqual(JSON.parse(output), {
4545
originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs],
46-
currentArgv: [embedtest, ...runSnapshotExecArgs],
46+
currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs],
4747
});
4848
return true;
4949
},
Collapse file

‎test/embedding/test-embedding-snapshot-without-code-cache.js‎

Copy file name to clipboardExpand all lines: test/embedding/test-embedding-snapshot-without-code-cache.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ spawnSyncAndAssert(
4343
stdout(output) {
4444
assert.deepStrictEqual(JSON.parse(output), {
4545
originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs],
46-
currentArgv: [embedtest, ...runSnapshotExecArgs],
46+
currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs],
4747
});
4848
return true;
4949
},
Collapse file

‎test/fixtures/snapshot/typescript-main.js‎

Copy file name to clipboardExpand all lines: test/fixtures/snapshot/typescript-main.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const v8 = require('v8');
99
const assert = require('assert');
1010

1111
v8.startupSnapshot.setDeserializeMainFunction(( { ts }) => {
12-
const input = process.argv[1];
13-
const output = process.argv[2];
12+
const input = process.argv[2];
13+
const output = process.argv[3];
1414
console.error(`Compiling ${input} to ${output}`);
1515
assert(input);
1616
assert(output);
Collapse file

‎test/fixtures/snapshot/v8-startup-snapshot-api.js‎

Copy file name to clipboardExpand all lines: test/fixtures/snapshot/v8-startup-snapshot-api.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
4848
// process.env and process.argv are refreshed during snapshot
4949
// deserialization.
5050
const lang = process.env.BOOK_LANG || 'en_US';
51-
const book = process.argv[1];
51+
const book = process.argv[2];
5252
const name = `${book}.${lang}.txt`;
5353
console.error('Reading', name);
5454
console.log(shelf.storage.get(name).toString());
Collapse file

‎test/parallel/test-snapshot-argv1.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-snapshot-argv1.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ require('v8').startupSnapshot.setDeserializeMainFunction(() => {
4949

5050
const stdout = JSON.parse(child.stdout.toString().trim());
5151
assert.deepStrictEqual(stdout, [
52+
process.execPath,
5253
process.execPath,
5354
'argv1',
5455
'argv2',

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.