From ec64a3014a05dd85f01ca1e4d441692b21054e5e Mon Sep 17 00:00:00 2001 From: Mark Bruning Date: Fri, 16 Sep 2022 21:22:55 +0000 Subject: [PATCH] feat(changed): Add --cached option --- packages/changed/README.md | 14 ++++++++++++++ packages/changed/src/commands/filter.ts | 10 +++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/changed/README.md b/packages/changed/README.md index 2242556..825540f 100644 --- a/packages/changed/README.md +++ b/packages/changed/README.md @@ -33,6 +33,16 @@ yarn changed list --git-range master yarn changed list --git-range 93a9ed8..4ef2c61 ``` +#### `--cached` + +Look only at staged changes in git. Useful for local development. + +Example: + +```sh +yarn changed list --cached +``` + #### `--include` Include workspaces. @@ -73,6 +83,10 @@ Run a command on changed workspaces and their dependents. This command relies on See `yarn changed list`. +#### `--cached` + +See `yarn changed list`. + #### `--include` See `yarn changed list`. diff --git a/packages/changed/src/commands/filter.ts b/packages/changed/src/commands/filter.ts index c1f9cb3..00f07d0 100644 --- a/packages/changed/src/commands/filter.ts +++ b/packages/changed/src/commands/filter.ts @@ -7,6 +7,9 @@ export abstract class FilterCommand extends BaseCommand { @Command.String('--git-range') public gitRange?: string; + @Command.Boolean('--cached') + public cached = false; + @Command.Array('--include') public include?: string[]; @@ -18,7 +21,12 @@ export abstract class FilterCommand extends BaseCommand { ): Promise { const { stdout } = await execUtils.execvp( 'git', - ['diff', '--name-only', ...(this.gitRange ? [this.gitRange] : [])], + [ + 'diff', + '--name-only', + ...(this.cached ? ['--cached'] : []), + ...(this.gitRange ? [this.gitRange] : []), + ], { cwd: project.cwd, strict: true,