* Returns whether to smart attach. The goal here is to avoid attaching to * scripts like `npm` or `webpack` which the user probably doesn't want to * debug. Unfortunately Node doesn't expose the originally argv to us where * we could detect a direct invokation of something like `npm install`, *
(env: IBootloaderInfo)
| 223 | * so we match against the script name. |
| 224 | */ |
| 225 | function shouldSmartAttach(env: IBootloaderInfo) { |
| 226 | const script: string | undefined = process.argv[1]; |
| 227 | if (!script) { |
| 228 | return true; // node REPL |
| 229 | } |
| 230 | |
| 231 | // otherwise, delegate to the patterns. Defaults exclude node_modules |
| 232 | return autoAttachSmartPatternMatches(script, env); |
| 233 | } |
| 234 | |
| 235 | function autoAttachSmartPatternMatches(script: string, env: IBootloaderInfo) { |
| 236 | if (!env.aaPatterns) { |
no test coverage detected