MCPcopy Index your code
hub / github.com/nodejs/node / buildSEA

Function buildSEA

test/common/sea.js:83–134  ·  view source on GitHub ↗
(fixtureDir, options = {})

Source from the content-addressed store, hash-verified

81}
82
83function 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
136function generateSEA(fixtureDir, options = {}) {
137 const {

Calls 10

spawnSyncAndAssertFunction · 0.85
signSEAFunction · 0.85
parseMethod · 0.65
assertFunction · 0.50
readFileSyncMethod · 0.45
resolveMethod · 0.45
writeFileSyncMethod · 0.45
logMethod · 0.45
toStringMethod · 0.45
existsSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…