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 @@ -13,6 +13,7 @@ Options:
-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
-r, --relative Pass relative filepaths to tasks
-v, --verbose Show task output even when tasks succeed; by default only failed output is shown
-h, --help Display this help message`;

Expand All @@ -26,6 +27,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
help: { type: 'boolean', short: 'h' },
'no-stash': { type: 'boolean' },
quiet: { type: 'boolean', short: 'q' },
relative: { type: 'boolean', short: 'r' },
verbose: { type: 'boolean', short: 'v' },
},
allowPositionals: false,
Expand Down Expand Up @@ -54,6 +56,7 @@ export async function runStagedCLI(args: string[]): Promise<void> {
concurrent: values.concurrent === undefined ? true : JSON.parse(values.concurrent),
config: stagedConfig,
quiet: values.quiet ?? false,
relative: values.relative ?? false,
stash: !values['no-stash'],
verbose: values.verbose ?? false,
});
Expand Down
11 changes: 11 additions & 0 deletions packages/rstack/test/cli/staged/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ for (const file of process.argv.slice(2)) {
}

console.log('staged task output');
console.log('staged file:', process.argv[2]);
`,
),
writeFile(path.join(cwd, 'file.txt'), 'initial\n'),
Expand Down Expand Up @@ -70,6 +71,7 @@ test('should display the staged help message', ({ execCli, expect }) => {
expect(output).toContain('--allow-empty');
expect(output).toContain('--no-stash');
expect(output).toContain('-q, --quiet');
expect(output).toContain('-r, --relative');
expect(output).toContain('-v, --verbose');
expect(output).toContain('-h, --help');
});
Expand Down Expand Up @@ -122,3 +124,12 @@ for (const option of ['--quiet', '-q']) {
});
});
}

for (const option of ['--relative', '-r']) {
test(`should pass relative filepaths with ${option}`, async ({ execCli, expect }) => {
await withGitFixture((cwd) => {
const output = execCli(`staged --allow-empty --verbose ${option}`, { cwd });
expect(output).toContain('staged file: file.txt');
});
});
}