Skip to content

Commit

Permalink
Merge pull request #35 from mbruning24/add-changed-cached-option
Browse files Browse the repository at this point in the history
feat(changed): Add --cached option
  • Loading branch information
tommy351 committed Sep 21, 2022
2 parents 67a2686 + ec64a30 commit 7126887
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/changed/README.md
Expand Up @@ -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.
Expand Down Expand Up @@ -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`.
Expand Down
10 changes: 9 additions & 1 deletion packages/changed/src/commands/filter.ts
Expand Up @@ -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[];

Expand All @@ -18,7 +21,12 @@ export abstract class FilterCommand extends BaseCommand {
): Promise<readonly Workspace[]> {
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,
Expand Down

0 comments on commit 7126887

Please sign in to comment.