Skip to content

Commit 1f2a760

Browse files
committed
feat: add quiet option to staged command
1 parent 8200cca commit 1f2a760

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

packages/rstack/src/staged.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Options:
1212
--allow-empty Allow empty commits when tasks revert all staged changes
1313
-p, --concurrent <number|boolean> The number of tasks to run concurrently, or false for serial
1414
--no-stash Disable the backup stash. Implies "--no-revert".
15+
-q, --quiet Disable lint-staged's own console output
1516
-v, --verbose Show task output even when tasks succeed; by default only failed output is shown
1617
-h, --help Display this help message`;
1718

@@ -24,6 +25,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
2425
concurrent: { type: 'string', short: 'p' },
2526
help: { type: 'boolean', short: 'h' },
2627
'no-stash': { type: 'boolean' },
28+
quiet: { type: 'boolean', short: 'q' },
2729
verbose: { type: 'boolean', short: 'v' },
2830
},
2931
allowPositionals: false,
@@ -51,6 +53,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
5153
allowEmpty: values['allow-empty'] ?? values.allowEmpty ?? false,
5254
concurrent: values.concurrent === undefined ? true : JSON.parse(values.concurrent),
5355
config: stagedConfig,
56+
quiet: values.quiet ?? false,
5457
stash: !values['no-stash'],
5558
verbose: values.verbose ?? false,
5659
});

packages/rstack/test/cli/staged/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ test('should display the staged help message', ({ execCli, expect }) => {
6969
expect(output).toContain('Runs lint-staged with tasks from define.staged in rstack.config.');
7070
expect(output).toContain('--allow-empty');
7171
expect(output).toContain('--no-stash');
72+
expect(output).toContain('-q, --quiet');
7273
expect(output).toContain('-v, --verbose');
7374
expect(output).toContain('-h, --help');
7475
});
@@ -112,3 +113,12 @@ test('should run staged tasks without a backup stash', async ({ execCli, expect
112113
expect(output).toContain('Skipping backup because `--no-stash` was used');
113114
});
114115
});
116+
117+
for (const option of ['--quiet', '-q']) {
118+
test(`should suppress lint-staged output with ${option}`, async ({ execCli, expect }) => {
119+
await withGitFixture((cwd) => {
120+
const output = execCli(`staged --allow-empty ${option}`, { cwd });
121+
expect(output).toBe('');
122+
});
123+
});
124+
}

0 commit comments

Comments
 (0)