Skip to content

Commit c2587f6

Browse files
committed
test(cli): declare the tsc child's environment in the scaffold typecheck pin
`check:cli-test-child-env` (#11595) requires every spawn under `packages/cli/test/**` to declare its child's `env`, so that what the child inherits is legible at the call site instead of being the vitest worker's environment by default. The new pin's `spawnSync` passed an options object with no `env` key and the gate named it. Routed through `childEnv()`, this directory's choke point, with `NO_COLOR` to match the `--pretty false` already passed to tsc. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D47qPfEWVPmhguWgBZCi5N
1 parent 8f6d9ab commit c2587f6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

packages/cli/test/scaffold-emission-typechecks.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import {
104104
SCAFFOLD_TSCONFIG_INCLUDE_SRC_ONLY,
105105
} from '../src/commands/init.js';
106106
import { GENERATOR_SCAFFOLD_TARGETS } from '../src/commands/generate.js';
107+
import { childEnv } from './helpers/serve-process.js';
107108

108109
const HERE = path.dirname(fileURLToPath(import.meta.url));
109110

@@ -120,13 +121,22 @@ afterAll(() => {
120121
const PROJECT_NAME = 'my-app';
121122
const STEM = 'probe_thing';
122123

123-
/** Run the emitted project's own `typecheck` script: `tsc --noEmit`. */
124+
/**
125+
* Run the emitted project's own `typecheck` script: `tsc --noEmit`.
126+
*
127+
* The child's environment is DECLARED (`check:cli-test-child-env`, #11595):
128+
* every spawn under `packages/cli/test/**` owes one, so that what a child
129+
* inherits is legible at the call site rather than being the vitest worker's
130+
* environment by default. `childEnv()` is this directory's choke point — the
131+
* environment minus the `VITEST_*` family — and `NO_COLOR` pairs with
132+
* `--pretty false` to keep tsc's diagnostics greppable in the failure message.
133+
*/
124134
function typecheckProject(root: string): { code: number; output: string } {
125135
const tscBin = createRequire(import.meta.url).resolve('typescript/bin/tsc');
126136
const res = spawnSync(
127137
process.execPath,
128138
[tscBin, '--pretty', 'false', '--noEmit', '-p', root],
129-
{ cwd: root, encoding: 'utf-8' },
139+
{ cwd: root, encoding: 'utf-8', env: childEnv({ NO_COLOR: '1' }) },
130140
);
131141
return { code: res.status ?? 1, output: `${res.stdout ?? ''}${res.stderr ?? ''}` };
132142
}

0 commit comments

Comments
 (0)