GeezerVison is showing github.com — lib: insert argv[0] at argv[1] in setDeserializeMainFunction · nodejs/node@19c46ab
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -1355,7 +1355,7 @@ v8.startupSnapshot.setDeserializeMainFunction((shelf) => { | 1355 | 1355 | // process.env and process.argv are refreshed during snapshot | 1356 | 1356 | // deserialization. | 1357 | 1357 | const lang = process.env.BOOK_LANG || 'en_US'; | 1358 | | - const book = process.argv[1]; | | 1358 | + const book = process.argv[2]; | 1359 | 1359 | const name = `${book}.${lang}.txt`; | 1360 | 1360 | console.log(shelf.storage.get(name)); | 1361 | 1361 | }, shelf); | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/v8/startup_snapshot.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -109,10 +109,10 @@ function setDeserializeMainFunction(callback, data) { | 109 | 109 | markBootstrapComplete, | 110 | 110 | } = require('internal/process/pre_execution'); | 111 | 111 |
| 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]. | 115 | 112 | 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]); | 116 | 116 | markBootstrapComplete(); | 117 | 117 | callback(data); | 118 | 118 | }); | |
Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -43,7 +43,7 @@ spawnSyncAndAssert( | 43 | 43 | stdout(output) { | 44 | 44 | assert.deepStrictEqual(JSON.parse(output), { | 45 | 45 | originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs], | 46 | | - currentArgv: [embedtest, ...runSnapshotExecArgs], | | 46 | + currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs], | 47 | 47 | }); | 48 | 48 | return true; | 49 | 49 | }, | |
Collapse file Copy file name to clipboardExpand all lines: test/embedding/test-embedding-snapshot-basic.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,7 +43,7 @@ spawnSyncAndAssert( | 43 | 43 | stdout(output) { | 44 | 44 | assert.deepStrictEqual(JSON.parse(output), { | 45 | 45 | originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs], | 46 | | - currentArgv: [embedtest, ...runSnapshotExecArgs], | | 46 | + currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs], | 47 | 47 | }); | 48 | 48 | return true; | 49 | 49 | }, | |
Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -43,7 +43,7 @@ spawnSyncAndAssert( | 43 | 43 | stdout(output) { | 44 | 44 | assert.deepStrictEqual(JSON.parse(output), { | 45 | 45 | originalArgv: [embedtest, '__node_anonymous_main', ...buildSnapshotExecArgs], | 46 | | - currentArgv: [embedtest, ...runSnapshotExecArgs], | | 46 | + currentArgv: [embedtest, embedtest, ...runSnapshotExecArgs], | 47 | 47 | }); | 48 | 48 | return true; | 49 | 49 | }, | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/snapshot/typescript-main.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,8 +9,8 @@ const v8 = require('v8'); | 9 | 9 | const assert = require('assert'); | 10 | 10 |
| 11 | 11 | 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]; | 14 | 14 | console.error(`Compiling ${input} to ${output}`); | 15 | 15 | assert(input); | 16 | 16 | assert(output); | |
Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -48,7 +48,7 @@ v8.startupSnapshot.setDeserializeMainFunction((shelf) => { | 48 | 48 | // process.env and process.argv are refreshed during snapshot | 49 | 49 | // deserialization. | 50 | 50 | const lang = process.env.BOOK_LANG || 'en_US'; | 51 | | - const book = process.argv[1]; | | 51 | + const book = process.argv[2]; | 52 | 52 | const name = `${book}.${lang}.txt`; | 53 | 53 | console.error('Reading', name); | 54 | 54 | console.log(shelf.storage.get(name).toString()); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-snapshot-argv1.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,6 +49,7 @@ require('v8').startupSnapshot.setDeserializeMainFunction(() => { | 49 | 49 |
| 50 | 50 | const stdout = JSON.parse(child.stdout.toString().trim()); | 51 | 51 | assert.deepStrictEqual(stdout, [ | | 52 | + process.execPath, | 52 | 53 | process.execPath, | 53 | 54 | 'argv1', | 54 | 55 | 'argv2', | |
|