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
9 changes: 6 additions & 3 deletions packages/rstack/src/staged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Usage:
Runs lint-staged with tasks from define.staged in rstack.config.

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
-v, --verbose show task output even when tasks succeed; by default only failed output is shown
--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".
-v, --verbose Show task output even when tasks succeed; by default only failed output is shown
-h, --help Display this help message`;

export async function runStagedCLI(args: string[]): Promise<void> {
Expand All @@ -22,6 +23,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
allowEmpty: { type: 'boolean' },
concurrent: { type: 'string', short: 'p' },
help: { type: 'boolean', short: 'h' },
'no-stash': { type: 'boolean' },
verbose: { type: 'boolean', short: 'v' },
},
allowPositionals: false,
Expand Down Expand Up @@ -49,6 +51,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,
stash: !values['no-stash'],
verbose: values.verbose ?? false,
});
if (!success) {
Expand Down
8 changes: 8 additions & 0 deletions packages/rstack/test/cli/staged/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ test('should display the staged help message', ({ execCli, expect }) => {
expect(output).toContain('Usage:\n $ rs staged [options]');
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('-v, --verbose');
expect(output).toContain('-h, --help');
});
Expand Down Expand Up @@ -104,3 +105,10 @@ for (const option of ['--verbose', '-v']) {
});
});
}

test('should run staged tasks without a backup stash', async ({ execCli, expect }) => {
await withGitFixture((cwd) => {
const output = execCli('staged --allow-empty --no-stash 2>&1', { cwd });
expect(output).toContain('Skipping backup because `--no-stash` was used');
});
});