Skip to content

Commit e8db73a

Browse files
authored
feat: add concurrent option to staged command (#9)
1 parent bcafc18 commit e8db73a

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

packages/rstack/src/staged.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ Usage:
99
Runs lint-staged with tasks from define.staged in rstack.config.
1010
1111
Options:
12-
--allow-empty Allow empty commits when tasks revert all staged changes
13-
-h, --help Display this help message`;
12+
--allow-empty allow empty commits when tasks revert all staged changes
13+
-p, --concurrent <number|boolean> the number of tasks to run concurrently, or false for serial
14+
-h, --help Display this help message`;
1415

1516
export async function runStagedCLI(args: string[]): Promise<void> {
1617
const { values } = parseArgs({
1718
args,
1819
options: {
1920
'allow-empty': { type: 'boolean' },
2021
allowEmpty: { type: 'boolean' },
22+
concurrent: { type: 'string', short: 'p' },
2123
help: { type: 'boolean', short: 'h' },
2224
},
2325
allowPositionals: false,
@@ -43,6 +45,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
4345
);
4446
const success = await lintStaged({
4547
allowEmpty: values['allow-empty'] ?? values.allowEmpty ?? false,
48+
concurrent: values.concurrent === undefined ? true : JSON.parse(values.concurrent),
4649
config: stagedConfig,
4750
});
4851
if (!success) {

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,20 @@ test('should prevent an empty commit by default', async ({ execCli, expect }) =>
7979
});
8080
});
8181

82-
test(`should allow an empty commit with --allow-empty`, async ({ execCli }) => {
82+
test('should allow an empty commit with --allow-empty', async ({ execCli }) => {
8383
await withGitFixture((cwd) => {
8484
execCli(`staged --allow-empty`, { cwd });
8585
});
8686
});
87+
88+
test('should run staged tasks with --concurrent false', async ({ execCli }) => {
89+
await withGitFixture((cwd) => {
90+
execCli(`staged --allow-empty --concurrent false`, { cwd });
91+
});
92+
});
93+
94+
test('should run staged tasks with -p 1', async ({ execCli }) => {
95+
await withGitFixture((cwd) => {
96+
execCli(`staged --allow-empty -p 1`, { cwd });
97+
});
98+
});

0 commit comments

Comments
 (0)