Lines 133-173javascript
133 let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
135 subpath = `package/${subpath}`;
136 while (offset < buffer.length) {
137 let name = str(offset, 100);
138 let size = parseInt(str(offset + 124, 12), 8);
141 if (name === subpath) return buffer.subarray(offset, offset + size);
142 offset += size + 511 & ~511;
145 throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
147function installUsingNPM(pkg, subpath, binPath) {
148 const env = { ...process.env, npm_config_global: void 0 };
149 const libDir = import_path2.default.dirname(require.resolve("workerd"));
150 const installDir = import_path2.default.join(libDir, "npm-install");
151 import_fs.default.mkdirSync(installDir);
153 import_fs.default.writeFileSync(import_path2.default.join(installDir, "package.json"), "{}");
154 import_child_process.default.execSync(
155 `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"1.20260704.1"}`,
156 { cwd: installDir, stdio: "pipe", env }
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
install.jsView on unpkg · L153 158 const installedBinPath = import_path2.default.join(
164 import_fs.default.renameSync(installedBinPath, binPath);
167 removeRecursive(installDir);
172function removeRecursive(dir) {
173 for (const entry of import_fs.default.readdirSync(dir)) {