Skip to content

Commit 4d20d1c

Browse files
authored
Make 'yarn lint --fix' work as an alias to 'yarn lint-fix'. (#5563)
Because I'm so used to `mach lint --fix`, I keep running `yarn lint --fix` when I need `yarn lint-fix`. Making `yarn lint --fix` work seems easier than fixing my muscle memory.
2 parents 531ad81 + 9eccc42 commit 4d20d1c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bin/output-fixing-commands.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ const fixingCommands = {
1616
};
1717

1818
const command = process.argv.slice(2);
19+
const currentScriptName = process.env.npm_lifecycle_event;
20+
21+
// Redirect the main lint command, but not individual commands.
22+
if (currentScriptName === 'lint' && command.includes('--fix')) {
23+
console.log(`🔧 Detected --fix flag, running: yarn lint-fix`);
24+
const result = cp.spawnSync('yarn', ['lint-fix'], { stdio: 'inherit' });
25+
process.exitCode = result.status;
26+
process.exit();
27+
}
1928

2029
const result = cp.spawnSync(command[0], command.slice(1), { stdio: 'inherit' });
2130

2231
if (result.status !== 0) {
2332
process.exitCode = result.status;
24-
const currentScriptName = process.env.npm_lifecycle_event;
2533
if (currentScriptName && currentScriptName in fixingCommands) {
2634
console.log(
2735
'💡 You might be able to fix the error by running `yarn ' +

0 commit comments

Comments
 (0)