Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(vibe-tests): run pnpm through cmd.exe on Windows in more scripts (#5843)

Ojas Mutreja595cfd38f2cc
diff --git a/internal/vibe-tests/scripts/fixture-browser.mjs b/internal/vibe-tests/scripts/fixture-browser.mjs
index 78bce49116..0a723abadb 100644
--- a/internal/vibe-tests/scripts/fixture-browser.mjs
+++ b/internal/vibe-tests/scripts/fixture-browser.mjs
@@ -28,11 +28,28 @@ const CONTRAST_PROBES = [
['destructive action', 'destructive-action'],
];
-function run(command, args, cwd) {
- const result = spawnSync(command, args, {cwd, encoding: 'utf8'});
+/**
+ * pnpm is a .cmd (batch) file on Windows. spawnSync can only run a batch
+ * file through a shell — a bare 'pnpm' fails with ENOENT and an explicit
+ * 'pnpm.cmd' still fails with EINVAL (batch files need a shell even named
+ * exactly). Shelling out through cmd.exe /c directly, rather than
+ * spawnSync's shell:true, avoids Node's shell-argument-escaping deprecation
+ * warning (DEP0190) — every argument here is a hardcoded literal, never
+ * user input, so we build the argv ourselves instead of asking spawnSync to
+ * build a shell string. See internal/vibe-tests/src/fixture-suite.mjs for
+ * the same pattern.
+ */
+function runPnpm(args, cwd) {
+ const result =
+ process.platform === 'win32'
+ ? spawnSync('cmd.exe', ['/d', '/s', '/c', 'pnpm', ...args], {
+ cwd,
+ encoding: 'utf8',
+ })
+ : spawnSync('pnpm', args, {cwd, encoding: 'utf8'});
if (result.status !== 0) {
throw new Error(
- `${command} ${args.join(' ')} failed in ${cwd}\n${result.stdout}${result.stderr}`,
+ `pnpm ${args.join(' ')} failed in ${cwd}\n${result.stdout ?? ''}${result.stderr ?? result.error?.message ?? ''}`,
);
}
}
@@ -221,9 +238,9 @@ async function main() {
let browser;
try {
copyFixture(FIXTURE_ID, sandbox);
- run('pnpm', ['install', '--frozen-lockfile', '--ignore-scripts'], sandbox);
- run('pnpm', ['typecheck'], sandbox);
- run('pnpm', ['build'], sandbox);
+ runPnpm(['install', '--frozen-lockfile', '--ignore-scripts'], sandbox);
+ runPnpm(['typecheck'], sandbox);
+ runPnpm(['build'], sandbox);
server = await preview({
root: sandbox,
logLevel: 'silent',
diff --git a/internal/vibe-tests/setup-test/run-setup.mjs b/internal/vibe-tests/setup-test/run-setup.mjs
index 711919d7c4..0dbd3251d6 100644
--- a/internal/vibe-tests/setup-test/run-setup.mjs
+++ b/internal/vibe-tests/setup-test/run-setup.mjs
@@ -75,6 +75,23 @@ const write = (file, content) => {
};
const run = (command, commandArgs, cwd) =>
execFileSync(command, commandArgs, {cwd, stdio: 'pipe', encoding: 'utf8'});
+// pnpm is a .cmd (batch) file on Windows. execFileSync, like spawnSync, can
+// only run a batch file through a shell — a bare 'pnpm' fails with ENOENT
+// and an explicit 'pnpm.cmd' still fails with EINVAL (batch files need a
+// shell even named exactly). Shelling out through cmd.exe /c directly,
+// rather than execFileSync's shell:true, avoids Node's
+// shell-argument-escaping deprecation warning (DEP0190) — every argument
+// here is a hardcoded literal, never user input, so we build the argv
+// ourselves instead of asking execFileSync to build a shell string. See
+// internal/vibe-tests/src/fixture-suite.mjs for the same pattern.
+const runPnpm = (pnpmArgs, cwd) =>
+ process.platform === 'win32'
+ ? execFileSync('cmd.exe', ['/d', '/s', '/c', 'pnpm', ...pnpmArgs], {
+ cwd,
+ stdio: 'pipe',
+ encoding: 'utf8',
+ })
+ : execFileSync('pnpm', pnpmArgs, {cwd, stdio: 'pipe', encoding: 'utf8'});
function copyDirectory(source, destination) {
ensureDir(destination);
@@ -94,7 +111,7 @@ function prepareDependencies(fixtureId) {
for (const file of ['package.json', 'pnpm-lock.yaml']) {
fs.copyFileSync(path.join(fixtureRoot, file), path.join(depsDir, file));
}
- run('pnpm', ['install', '--frozen-lockfile', '--ignore-scripts'], depsDir);
+ runPnpm(['install', '--frozen-lockfile', '--ignore-scripts'], depsDir);
return depsDir;
}
@@ -133,7 +150,7 @@ function createSandbox(fixtureId, sandboxDir, depsDir) {
copyFixture(fixtureId, sandboxDir);
linkDependencies(depsDir, sandboxDir);
installLoggingShim(sandboxDir);
- run('pnpm', ['build'], sandboxDir);
+ runPnpm(['build'], sandboxDir);
}
function appendGuidance(sandboxDir, guidanceFile) {
diff --git a/internal/vibe-tests/setup-test/setup-canonical.test.ts b/internal/vibe-tests/setup-test/setup-canonical.test.ts
index 62390d57fb..0456003af4 100644
--- a/internal/vibe-tests/setup-test/setup-canonical.test.ts
+++ b/internal/vibe-tests/setup-test/setup-canonical.test.ts
@@ -62,6 +62,31 @@ function run(command: string, args: string[], cwd: string) {
});
}
+// pnpm is a .cmd (batch) file on Windows. execFileSync, like spawnSync, can
+// only run a batch file through a shell — a bare 'pnpm' fails with ENOENT
+// and an explicit 'pnpm.cmd' still fails with EINVAL (batch files need a
+// shell even named exactly). Shelling out through cmd.exe /c directly,
+// rather than execFileSync's shell:true, avoids Node's
+// shell-argument-escaping deprecation warning (DEP0190) — every argument
+// here is a hardcoded literal, never user input, so we build the argv
+// ourselves instead of asking execFileSync to build a shell string. See
+// internal/vibe-tests/src/fixture-suite.mjs for the same pattern.
+function runPnpm(args: string[], cwd: string) {
+ return process.platform === 'win32'
+ ? run('cmd.exe', ['/d', '/s', '/c', 'pnpm', ...args], cwd)
+ : run('pnpm', args, cwd);
+}
+
+// The non-throwing counterpart to runPnpm, for the cases below where a
+// failing pnpm invocation is the assertion under test, not an error: same
+// cmd.exe routing on win32, but returns spawnSync's result object instead of
+// throwing on a non-zero exit.
+function spawnPnpm(args: string[], options: Parameters<typeof spawnSync>[2]) {
+ return process.platform === 'win32'
+ ? spawnSync('cmd.exe', ['/d', '/s', '/c', 'pnpm', ...args], options)
+ : spawnSync('pnpm', args, options);
+}
+
function edit(file: string, transform: (source: string) => string) {
const source = fs.readFileSync(file, 'utf8');
const next = transform(source);
@@ -75,14 +100,14 @@ function ensurePackageBuilds() {
if (
!fs.existsSync(path.join(REPO_ROOT, 'packages/core/dist/Button/index.js'))
) {
- run('pnpm', ['-F', '@astryxdesign/core', 'build'], REPO_ROOT);
+ runPnpm(['-F', '@astryxdesign/core', 'build'], REPO_ROOT);
}
if (
!fs.existsSync(
path.join(REPO_ROOT, 'packages/themes/neutral/dist/theme.css'),
)
) {
- run('pnpm', ['-F', '@astryxdesign/theme-neutral', 'build'], REPO_ROOT);
+ runPnpm(['-F', '@astryxdesign/theme-neutral', 'build'], REPO_ROOT);
}
}
@@ -97,7 +122,7 @@ function dependencyRoot(fixture: string) {
temporaryDirectories.push(parent);
const root = path.join(parent, 'app');
copyFixture(fixture, root);
- run('pnpm', ['install', '--frozen-lockfile', '--ignore-scripts'], root);
+ runPnpm(['install', '--frozen-lockfile', '--ignore-scripts'], root);
dependencyRoots.set(fixture, root);
return root;
}
@@ -2123,7 +2148,7 @@ describeCanonical('canonical pnpm build approval', () => {
// spawnSync rather than execFileSync's throwing form: a failing install is
// the assertion in half these cases, not an error.
const install = (app: string) =>
- spawnSync('pnpm', ['install'], {
+ spawnPnpm(['install'], {
cwd: app,
encoding: 'utf8',
env: {...process.env, CI: 'true'},
@@ -2147,7 +2172,7 @@ describeCanonical('canonical pnpm build approval', () => {
expect(
fs.existsSync(path.join(app, 'node_modules', PACKAGE, 'package.json')),
).toBe(true);
- const built = spawnSync('pnpm', ['build'], {
+ const built = spawnPnpm(['build'], {
cwd: app,
encoding: 'utf8',
env: {...process.env, CI: 'true'},
diff --git a/internal/vibe-tests/setup-test/setup-measure.mjs b/internal/vibe-tests/setup-test/setup-measure.mjs
index d876ff9c88..cb89f626c8 100644
--- a/internal/vibe-tests/setup-test/setup-measure.mjs
+++ b/internal/vibe-tests/setup-test/setup-measure.mjs
@@ -66,15 +66,28 @@ export function parseLayerOrder(css) {
* `CI=true` and piped stdio keep it non-interactive: a package manager or
* bundler that finds no TTY must not stop to ask anything, and a spinner that
* probes for one must not error out. Measurement is unattended by definition.
+ *
+ * pnpm is a .cmd (batch) file on Windows; spawnSync can only run a batch
+ * file through a shell, so shell out through cmd.exe /c directly rather than
+ * spawnSync's shell:true. See internal/vibe-tests/src/fixture-suite.mjs for
+ * the same pattern.
*/
function build(appDir) {
const started = Date.now();
- const result = spawnSync('pnpm', ['build'], {
- cwd: appDir,
- encoding: 'utf8',
- env: {...process.env, CI: 'true'},
- stdio: ['ignore', 'pipe', 'pipe'],
- });
+ const result =
+ process.platform === 'win32'
+ ? spawnSync('cmd.exe', ['/d', '/s', '/c', 'pnpm', 'build'], {
+ cwd: appDir,
+ encoding: 'utf8',
+ env: {...process.env, CI: 'true'},
+ stdio: ['ignore', 'pipe', 'pipe'],
+ })
+ : spawnSync('pnpm', ['build'], {
+ cwd: appDir,
+ encoding: 'utf8',
+ env: {...process.env, CI: 'true'},
+ stdio: ['ignore', 'pipe', 'pipe'],
+ });
return {
ok: result.status === 0,
status: result.status ?? -1,