fix(docs): spawn nested npm through Node on Windows

main
dajiaohuang 2026-09-29 15:58:45 +08:00 committed by lyingbug
parent 75d2c1b583
commit 0c6b30cfa7
1 changed files with 4 additions and 1 deletions

View File

@ -4,7 +4,10 @@ import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
function run(dir, script) {
const result = spawnSync('npm', ['run', script], { cwd: resolve(root, dir), stdio: 'inherit' });
const npmCLI = process.env.npm_execpath;
if (!npmCLI) throw new Error('Run the site build through npm so npm_execpath is available.');
const result = spawnSync(process.execPath, [npmCLI, 'run', script], { cwd: resolve(root, dir), stdio: 'inherit' });
if (result.error) throw new Error(`Could not run npm ${script}: ${result.error.message}`);
if (result.status !== 0) process.exit(result.status || 1);
}
for (const dir of ['homepage', '.']) {