* Launches the program.
(runData: IRunData<INodeLaunchConfiguration>)
| 103 | * Launches the program. |
| 104 | */ |
| 105 | protected async launchProgram(runData: IRunData<INodeLaunchConfiguration>): Promise<void> { |
| 106 | if (runData.params.program) { |
| 107 | runData.params.program = await this.tryGetCompiledFile(runData.params.program); |
| 108 | } |
| 109 | |
| 110 | this.attachSimplePort = await this.getSimpleAttachPortIfAny(runData.params); |
| 111 | const doLaunch = async (restartPolicy: IRestartPolicy) => { |
| 112 | // Close any existing program. We intentionally don't wait for stop() to |
| 113 | // finish, since doing so will shut down the server. |
| 114 | if (this.program) { |
| 115 | this.program.stop(); // intentionally not awaited on |
| 116 | } |
| 117 | |
| 118 | const binary = await this.resolveNodePath( |
| 119 | runData.params, |
| 120 | runData.params.runtimeExecutable || undefined, |
| 121 | ); |
| 122 | |
| 123 | const warning = binary.warning; |
| 124 | if (warning) { |
| 125 | runData.context.dap.output({ |
| 126 | category: 'stderr', |
| 127 | output: warning.message, |
| 128 | }); |
| 129 | } |
| 130 | |
| 131 | const callbackFile = new CallbackFile<IProcessTelemetry>(); |
| 132 | let env = await this.resolveEnvironment(runData, binary, { |
| 133 | fileCallback: callbackFile.path, |
| 134 | }); |
| 135 | |
| 136 | if (this.attachSimplePort) { |
| 137 | if (!runData.params.attachSimplePort) { |
| 138 | runData.context.dap.output({ |
| 139 | category: 'stderr', |
| 140 | output: |
| 141 | 'Using legacy attach mode for --inspect-brk in npm scripts. We recommend removing --inspect-brk, and using `stopOnEntry` in your launch.json if you need it.', |
| 142 | }); |
| 143 | } |
| 144 | |
| 145 | env = env.merge({ NODE_OPTIONS: null }); |
| 146 | } else { |
| 147 | env = hideDebugInfoFromConsole(binary, env); |
| 148 | } |
| 149 | |
| 150 | const options: INodeLaunchConfiguration = { ...runData.params, env: env.value }; |
| 151 | const experimentalNetworkFlag = '--experimental-network-inspection'; |
| 152 | if (runData.params.experimentalNetworking === 'off') { |
| 153 | // no-op |
| 154 | } else if ( |
| 155 | binary.has(Capability.UseExperimentalNetworking) |
| 156 | || runData.params.experimentalNetworking === 'on' |
| 157 | ) { |
| 158 | options.runtimeArgs = [experimentalNetworkFlag, ...options.runtimeArgs]; |
| 159 | } |
| 160 | |
| 161 | const launcher = this.launchers.find(l => l.canLaunch(options)); |
| 162 | if (!launcher) { |
nothing calls this directly
no test coverage detected