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

Options:
--allow-empty Allow empty commits when tasks revert all staged changes
-h, --help Display this help message`;
--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
-h, --help Display this help message`;

export async function runStagedCLI(args: string[]): Promise<void> {
const { values } = parseArgs({
args,
options: {
'allow-empty': { type: 'boolean' },
allowEmpty: { type: 'boolean' },
concurrent: { type: 'string', short: 'p' },
help: { type: 'boolean', short: 'h' },
},
allowPositionals: false,
Expand All @@ -43,6 +45,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
);
const success = await lintStaged({
allowEmpty: values['allow-empty'] ?? values.allowEmpty ?? false,
concurrent: values.concurrent === undefined ? true : JSON.parse(values.concurrent),
config: stagedConfig,
});
if (!success) {
Expand Down
14 changes: 13 additions & 1 deletion packages/rstack/test/cli/staged/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,20 @@ test('should prevent an empty commit by default', async ({ execCli, expect }) =>
});
});

test(`should allow an empty commit with --allow-empty`, async ({ execCli }) => {
test('should allow an empty commit with --allow-empty', async ({ execCli }) => {
await withGitFixture((cwd) => {
execCli(`staged --allow-empty`, { cwd });
});
});

test('should run staged tasks with --concurrent false', async ({ execCli }) => {
await withGitFixture((cwd) => {
execCli(`staged --allow-empty --concurrent false`, { cwd });
});
});

test('should run staged tasks with -p 1', async ({ execCli }) => {
await withGitFixture((cwd) => {
execCli(`staged --allow-empty -p 1`, { cwd });
});
});