Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/rstack/src/staged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Options:
--allow-empty Allow empty commits when tasks revert all staged changes
-p, --concurrent <number|boolean> The number of tasks to run concurrently, or false for serial
--no-stash Disable the backup stash. Implies "--no-revert".
-q, --quiet Disable lint-staged's own console output
-v, --verbose Show task output even when tasks succeed; by default only failed output is shown
-h, --help Display this help message`;

Expand All @@ -24,6 +25,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
concurrent: { type: 'string', short: 'p' },
help: { type: 'boolean', short: 'h' },
'no-stash': { type: 'boolean' },
quiet: { type: 'boolean', short: 'q' },
verbose: { type: 'boolean', short: 'v' },
},
allowPositionals: false,
Expand Down Expand Up @@ -51,6 +53,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
allowEmpty: values['allow-empty'] ?? values.allowEmpty ?? false,
concurrent: values.concurrent === undefined ? true : JSON.parse(values.concurrent),
config: stagedConfig,
quiet: values.quiet ?? false,
stash: !values['no-stash'],
verbose: values.verbose ?? false,
});
Expand Down
10 changes: 10 additions & 0 deletions packages/rstack/test/cli/staged/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ test('should display the staged help message', ({ execCli, expect }) => {
expect(output).toContain('Runs lint-staged with tasks from define.staged in rstack.config.');
expect(output).toContain('--allow-empty');
expect(output).toContain('--no-stash');
expect(output).toContain('-q, --quiet');
expect(output).toContain('-v, --verbose');
expect(output).toContain('-h, --help');
});
Expand Down Expand Up @@ -112,3 +113,12 @@ test('should run staged tasks without a backup stash', async ({ execCli, expect
expect(output).toContain('Skipping backup because `--no-stash` was used');
});
});

for (const option of ['--quiet', '-q']) {
test(`should suppress lint-staged output with ${option}`, async ({ execCli, expect }) => {
await withGitFixture((cwd) => {
const output = execCli(`staged --allow-empty ${option}`, { cwd });
expect(output).toBe('');
});
});
}