From d69cec965024cc2223f3495f6ff58ccb5b14095b Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 10 Jul 2026 14:55:03 +0800 Subject: [PATCH] feat: add debug option to staged command --- packages/rstack/src/staged.ts | 3 +++ packages/rstack/test/cli/staged/index.test.ts | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/packages/rstack/src/staged.ts b/packages/rstack/src/staged.ts index 16d785b..5fd1215 100644 --- a/packages/rstack/src/staged.ts +++ b/packages/rstack/src/staged.ts @@ -12,6 +12,7 @@ Options: --allow-empty Allow empty commits when tasks revert all staged changes -p, --concurrent The number of tasks to run concurrently, or false for serial --cwd Working directory to run all tasks in + -d, --debug Print additional debug information --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 @@ -26,6 +27,7 @@ export async function runStagedCLI(args: string[]): Promise { allowEmpty: { type: 'boolean' }, concurrent: { type: 'string', short: 'p' }, cwd: { type: 'string' }, + debug: { type: 'boolean', short: 'd' }, help: { type: 'boolean', short: 'h' }, 'no-stash': { type: 'boolean' }, quiet: { type: 'boolean', short: 'q' }, @@ -58,6 +60,7 @@ export async function runStagedCLI(args: string[]): Promise { concurrent: values.concurrent === undefined ? true : JSON.parse(values.concurrent), config: stagedConfig, cwd: values.cwd, + debug: values.debug ?? false, quiet: values.quiet ?? false, relative: values.relative ?? false, stash: !values['no-stash'], diff --git a/packages/rstack/test/cli/staged/index.test.ts b/packages/rstack/test/cli/staged/index.test.ts index 8e1bb06..15d9cce 100644 --- a/packages/rstack/test/cli/staged/index.test.ts +++ b/packages/rstack/test/cli/staged/index.test.ts @@ -70,6 +70,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('--cwd '); + expect(output).toContain('-d, --debug'); expect(output).toContain('--no-stash'); expect(output).toContain('-q, --quiet'); expect(output).toContain('-r, --relative'); @@ -101,6 +102,15 @@ for (const option of ['--concurrent false', '-p 1']) { }); } +for (const option of ['--debug', '-d']) { + test(`should print debug output with ${option}`, async ({ execCli, expect }) => { + await withGitFixture((cwd) => { + const output = execCli(`staged --allow-empty ${option} 2>&1`, { cwd }); + expect(output).toContain('lint-staged:'); + }); + }); +} + for (const option of ['--verbose', '-v']) { test(`should show successful task output with ${option}`, async ({ execCli, expect }) => { await withGitFixture((cwd) => {