MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / verifyLayout

Function verifyLayout

scripts/download-node.mjs:169–194  ·  view source on GitHub ↗

* Confirm the extracted tree has the binaries we depend on. * On Unix Node puts them in bin/; on Windows they live at the root.

(dir, platform)

Source from the content-addressed store, hash-verified

167 * On Unix Node puts them in bin/; on Windows they live at the root.
168 */
169function verifyLayout(dir, platform) {
170 const isWin = platform === "win32";
171 const required = isWin
172 ? ["node.exe", "npm.cmd", "npx.cmd"]
173 : ["bin/node", "bin/npm", "bin/npx"];
174 for (const rel of required) {
175 const p = join(dir, rel);
176 if (!existsSync(p)) {
177 throw new Error(
178 `Expected ${rel} in extracted Node distribution but it is missing ` +
179 `at ${p}. Did the tarball layout change?`,
180 );
181 }
182 ensureExecutable(p);
183 }
184
185 // npm/npx are wrapper scripts that invoke node against npm's JS entry
186 // points; verify the targets exist too so a packaged build doesn't ship
187 // a half-broken installation.
188 const npmCli = isWin
189 ? join(dir, "node_modules", "npm", "bin", "npm-cli.js")
190 : join(dir, "lib", "node_modules", "npm", "bin", "npm-cli.js");
191 if (!existsSync(npmCli)) {
192 throw new Error(`Bundled Node is missing npm-cli.js at ${npmCli}`);
193 }
194}
195
196// ── Pruning ──────────────────────────────────────────────────────────────────
197

Callers 1

mainFunction · 0.85

Calls 1

ensureExecutableFunction · 0.85

Tested by

no test coverage detected