(fixtureDir, options = {})
| 81 | } |
| 82 | |
| 83 | function buildSEA(fixtureDir, options = {}) { |
| 84 | const { |
| 85 | workingDir = tmpdir.path, |
| 86 | configPath = 'sea-config.json', |
| 87 | verifyWorkflow = false, |
| 88 | failure, |
| 89 | } = options; |
| 90 | |
| 91 | // Copy fixture files to working directory if they are different. |
| 92 | if (fixtureDir !== workingDir) { |
| 93 | fs.cpSync(fixtureDir, workingDir, { recursive: true }); |
| 94 | } |
| 95 | |
| 96 | // Parse the config to get the output file path, if on Windows, ensure it ends with .exe |
| 97 | const config = JSON.parse(fs.readFileSync(path.resolve(workingDir, configPath))); |
| 98 | assert.strictEqual(typeof config.output, 'string'); |
| 99 | if (process.platform === 'win32') { |
| 100 | if (!config.output.endsWith('.exe')) { |
| 101 | config.output += '.exe'; |
| 102 | } |
| 103 | if (config.executable && !config.executable.endsWith('.exe')) { |
| 104 | config.executable += '.exe'; |
| 105 | } |
| 106 | fs.writeFileSync(path.resolve(workingDir, configPath), JSON.stringify(config, null, 2)); |
| 107 | } |
| 108 | |
| 109 | // Build the SEA. |
| 110 | const child = spawnSyncAndAssert(process.execPath, ['--build-sea', configPath], { |
| 111 | cwd: workingDir, |
| 112 | env: { |
| 113 | NODE_DEBUG_NATIVE: 'SEA', |
| 114 | ...process.env, |
| 115 | }, |
| 116 | }, failure === undefined ? { |
| 117 | status: 0, |
| 118 | signal: null, |
| 119 | } : { |
| 120 | stderr: failure, |
| 121 | status: 1, |
| 122 | }); |
| 123 | |
| 124 | if (failure !== undefined) { |
| 125 | // Log more information, otherwise it's hard to debug failures from CI. |
| 126 | console.log(child.stderr.toString()); |
| 127 | return child; |
| 128 | } |
| 129 | |
| 130 | const outputFile = path.resolve(workingDir, config.output); |
| 131 | assert(fs.existsSync(outputFile), `Expected SEA output file ${outputFile} to exist`); |
| 132 | signSEA(outputFile, verifyWorkflow); |
| 133 | return outputFile; |
| 134 | } |
| 135 | |
| 136 | function generateSEA(fixtureDir, options = {}) { |
| 137 | const { |
no test coverage detected
searching dependent graphs…