* @inheritdoc
(
cdp: Cdp.Api,
run: IRunData<INodeLaunchConfiguration>,
{ targetId }: Cdp.Target.TargetInfo,
)
| 248 | * @inheritdoc |
| 249 | */ |
| 250 | protected createLifecycle( |
| 251 | cdp: Cdp.Api, |
| 252 | run: IRunData<INodeLaunchConfiguration>, |
| 253 | { targetId }: Cdp.Target.TargetInfo, |
| 254 | ): INodeTargetLifecycleHooks { |
| 255 | return { |
| 256 | initialized: async () => { |
| 257 | if (this.attachSimplePort) { |
| 258 | await this.gatherTelemetryFromCdp(cdp, run); |
| 259 | } |
| 260 | |
| 261 | if (!run.params.stopOnEntry) { |
| 262 | return; |
| 263 | } |
| 264 | |
| 265 | // This is not an ideal stop-on-entry setup. The previous debug adapter |
| 266 | // had life easier because it could ask the Node process to stop from |
| 267 | // the get-go, but in our scenario the bootloader is the first thing |
| 268 | // which is run and something we don't want to break in. We just |
| 269 | // do our best to find the entrypoint from the run params. |
| 270 | const program = await tryGetProgramFromArgs(this.fsUtils, run.params); |
| 271 | if (!program) { |
| 272 | this.logger.warn(LogTag.Runtime, 'Could not resolve program entrypointfrom args'); |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | const breakpointId = '(?:entryBreakpoint){0}'; |
| 277 | const breakpointPath = absolutePathToFileUrl(program); |
| 278 | const urlRegexp = urlToRegex(breakpointPath) + breakpointId; |
| 279 | const breakpoint = await cdp.Debugger.setBreakpointByUrl({ |
| 280 | urlRegex: urlRegexp, |
| 281 | lineNumber: 0, |
| 282 | columnNumber: 0, |
| 283 | }); |
| 284 | |
| 285 | return breakpoint?.breakpointId |
| 286 | ? { cdpId: breakpoint?.breakpointId, path: breakpointPath } |
| 287 | : undefined; |
| 288 | }, |
| 289 | close: () => { |
| 290 | const processId = Number(targetId); |
| 291 | if (processId > 0) { |
| 292 | try { |
| 293 | process.kill(processId); |
| 294 | } catch (e) { |
| 295 | // ignored |
| 296 | } |
| 297 | } |
| 298 | }, |
| 299 | }; |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Gets the compiled version of the given target program, if it exists and |
nothing calls this directly
no test coverage detected