-
-
Notifications
You must be signed in to change notification settings - Fork 230
Open
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.
Description
Description
The fix in #2870 to auto-detect CLAUDECODE=1 and use machine format doesn't work because the --output option has a default value in the sade CLI definition.
Note: svelte-check --output machine works correctly. The bug is specifically in the auto-detection path when no --output flag is provided.
Minimal Reproduction
// Run: CLAUDECODE=1 node reproduce.js
// Expected output: "machine"
// Actual output: "human-verbose"
const outputFormats = ['human', 'human-verbose', 'machine', 'machine-verbose'];
// sade sets default: .option('--output', '...', 'human-verbose')
const opts = { output: 'human-verbose' };
function getOutputFormat(opts) {
if (outputFormats.includes(opts.output)) {
return opts.output; // ← Always returns here (default is valid)
} else if (process.env.CLAUDECODE === '1') {
return 'machine'; // ← Never reached
}
return 'human-verbose';
}
console.log('CLAUDECODE:', process.env.CLAUDECODE);
console.log('Result:', getOutputFormat(opts));Output:
CLAUDECODE: 1
Result: human-verbose
Root Cause
In packages/svelte-check/src/index.ts, the sade option definition provides a default:
.option('--output', '...', 'human-verbose') // ← Default valueThis means opts.output is always 'human-verbose' when user doesn't provide --output, so getOutputFormat() returns early before reaching the CLAUDECODE check.
Suggested Fix
Remove the default from .option():
.option('--output', 'What output format to use...') // No defaultAnd guard the check in getOutputFormat:
function getOutputFormat(opts) {
if (opts.output && outputFormats.includes(opts.output)) {
return opts.output;
} else if (process.env.CLAUDECODE === '1') {
return 'machine';
} else {
return 'human-verbose';
}
}Environment
- svelte-check: 4.3.4
- Node: 20.x
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FixedFixed in master branch. Pending production release.Fixed in master branch. Pending production release.