Files
pulse/frontend-modern/scripts/build-embed-assets.mjs
T
pulse-triage[bot] fbe15144b5 Run the locked embed builder without a Windows command shim
Native runtime verification now needs the real frontend build on Windows as well as Unix. Invoke the already installed Vite CLI with the same Node executable, keeping arguments out of a shell and avoiding npx.cmd executable handling. The asset inputs, build arguments, lock, documentation sync and embed copy are unchanged.

Contract-Neutral: Build command portability only; frontend content, API and agent lifecycle contracts are unchanged.
Change-source: pulse-maintainer
2026-10-06 02:22:31 +01:00

41 lines
1.4 KiB
JavaScript

import path from 'node:path';
import { spawn } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { withExclusiveLock } from '../../scripts/exclusive-lock.mjs';
import { syncEmbedDir } from './sync-embed-dist.mjs';
import { syncPublicDocs } from './sync-public-docs.mjs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const frontendRoot = path.resolve(__dirname, '..');
const repoRoot = path.resolve(frontendRoot, '..');
const lockPath = path.join(repoRoot, 'tmp', 'locks', 'frontend-embed-build.lock');
// Invoke the installed CLI with this Node executable. Windows .cmd shims
// require a shell and are not portable child_process.spawn executables.
const viteCLI = path.join(frontendRoot, 'node_modules', 'vite', 'bin', 'vite.js');
function run(command, args, options = {}) {
return new Promise((resolve, reject) => {
const child = spawn(command, args, { stdio: 'inherit', ...options });
child.on('error', reject);
child.on('close', (code) => {
if (code === 0) {
resolve();
return;
}
reject(new Error(`${command} ${args.join(' ')} exited with code ${code}`));
});
});
}
await withExclusiveLock(
lockPath,
async () => {
await syncPublicDocs();
await run(process.execPath, [viteCLI, 'build'], { cwd: frontendRoot });
await syncEmbedDir({ lock: false });
},
{ description: 'frontend embedded asset build' },
);