|
1 | 1 | #!/usr/bin/env node |
2 | 2 | 'use strict' |
| 3 | +;(async () => { |
| 4 | + const Module = require('node:module') |
| 5 | + const path = require('node:path') |
| 6 | + const rootPath = path.join(__dirname, '..') |
| 7 | + Module.enableCompileCache?.(path.join(rootPath, '.cache')) |
3 | 8 |
|
4 | | -const Module = require('node:module') |
5 | | -const path = require('node:path') |
6 | | -const rootPath = path.join(__dirname, '..') |
7 | | -Module.enableCompileCache?.(path.join(rootPath, '.cache')) |
8 | | -const process = require('node:process') |
| 9 | + const constants = require(path.join(rootPath, 'dist/constants.js')) |
| 10 | + const { spawn } = require( |
| 11 | + path.join(rootPath, 'external/@socketsecurity/registry/lib/spawn.js'), |
| 12 | + ) |
9 | 13 |
|
10 | | -const constants = require(path.join(rootPath, 'dist/constants.js')) |
11 | | -const { spawn } = require( |
12 | | - path.join(rootPath, 'external/@socketsecurity/registry/lib/spawn.js'), |
13 | | -) |
| 14 | + process.exitCode = 1 |
14 | 15 |
|
15 | | -process.exitCode = 1 |
16 | | - |
17 | | -spawn( |
18 | | - constants.execPath, |
19 | | - [ |
20 | | - ...constants.nodeNoWarningsFlags, |
21 | | - ...constants.nodeHardenFlags, |
22 | | - ...constants.nodeMemoryFlags, |
23 | | - ...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD |
24 | | - ? ['--require', constants.instrumentWithSentryPath] |
25 | | - : []), |
26 | | - constants.distCliPath, |
27 | | - ...process.argv.slice(2), |
28 | | - ], |
29 | | - { |
30 | | - env: { |
31 | | - ...process.env, |
32 | | - ...constants.processEnv, |
| 16 | + const spawnPromise = spawn( |
| 17 | + constants.execPath, |
| 18 | + [ |
| 19 | + ...constants.nodeNoWarningsFlags, |
| 20 | + ...constants.nodeHardenFlags, |
| 21 | + ...constants.nodeMemoryFlags, |
| 22 | + ...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD |
| 23 | + ? ['--require', constants.instrumentWithSentryPath] |
| 24 | + : []), |
| 25 | + constants.distCliPath, |
| 26 | + ...process.argv.slice(2), |
| 27 | + ], |
| 28 | + { |
| 29 | + env: { |
| 30 | + ...process.env, |
| 31 | + ...constants.processEnv, |
| 32 | + }, |
| 33 | + stdio: 'inherit', |
33 | 34 | }, |
34 | | - stdio: 'inherit', |
35 | | - }, |
36 | | -) |
37 | | - // See https://nodejs.org/api/all.html#all_child_process_event-exit. |
38 | | - .process.on('exit', (code, signalName) => { |
| 35 | + ) |
| 36 | + |
| 37 | + // See https://nodejs.org/api/child_process.html#event-exit. |
| 38 | + spawnPromise.process.on('exit', (code, signalName) => { |
39 | 39 | if (signalName) { |
40 | 40 | process.kill(process.pid, signalName) |
41 | | - } else if (code) { |
| 41 | + } else if (typeof code === 'number') { |
42 | 42 | // eslint-disable-next-line n/no-process-exit |
43 | 43 | process.exit(code) |
44 | 44 | } |
45 | 45 | }) |
| 46 | + |
| 47 | + await spawnPromise |
| 48 | +})() |
0 commit comments