(args?: string[], options?: SpawnSyncOptions)
| 7 | import { nodePath, rootPath } from './projectPaths'; |
| 8 | |
| 9 | export default async function spawnNode(args?: string[], options?: SpawnSyncOptions) { |
| 10 | if (!options) { |
| 11 | options = { |
| 12 | env: {}, |
| 13 | stdio: 'inherit', |
| 14 | }; |
| 15 | } |
| 16 | |
| 17 | const optionsWithFullEnvironment: SpawnSyncOptions = { |
| 18 | cwd: rootPath, |
| 19 | ...options, |
| 20 | env: { |
| 21 | ...process.env, |
| 22 | ...options.env, |
| 23 | }, |
| 24 | stdio: options.stdio ?? 'inherit', |
| 25 | }; |
| 26 | |
| 27 | console.log(`starting ${nodePath} ${args ? args.join(' ') : ''}`); |
| 28 | |
| 29 | const buffer = spawnSync(nodePath, args, optionsWithFullEnvironment); |
| 30 | |
| 31 | return { code: buffer.status, signal: buffer.signal, stdout: buffer.stdout }; |
| 32 | } |
no test coverage detected