(callback, data)
| 93 | |
| 94 | let deserializeMainIsSet = false; |
| 95 | function setDeserializeMainFunction(callback, data) { |
| 96 | throwIfNotBuildingSnapshot(); |
| 97 | // TODO(joyeecheung): In lib/internal/bootstrap/node.js, create a default |
| 98 | // main function to run the lib/internal/main scripts and make sure that |
| 99 | // the main function set in the snapshot building process takes precedence. |
| 100 | validateFunction(callback, 'callback'); |
| 101 | if (deserializeMainIsSet) { |
| 102 | throw new ERR_DUPLICATE_STARTUP_SNAPSHOT_MAIN_FUNCTION(); |
| 103 | } |
| 104 | deserializeMainIsSet = true; |
| 105 | |
| 106 | _setDeserializeMainFunction(function deserializeMain() { |
| 107 | const { |
| 108 | prepareMainThreadExecution, |
| 109 | markBootstrapComplete, |
| 110 | } = require('internal/process/pre_execution'); |
| 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 | prepareMainThreadExecution(false); |
| 116 | markBootstrapComplete(); |
| 117 | callback(data); |
| 118 | }); |
| 119 | } |
| 120 | |
| 121 | initializeCallbacks(); |
| 122 | module.exports = { |
no test coverage detected