feat(dev-infra): Add support for formatting all staged files (#38402)

Adds an ng-dev formatter option to format all of the staged files. This will can
be used to format only the staged files during the pre-commit hook.

PR Close #38402
This commit is contained in:
Joey Perrott
2020-08-11 16:08:35 -07:00
committed by Andrew Kushnir
parent a6292faa97
commit 28534d83ee
2 changed files with 19 additions and 1 deletions

View File

@ -27,6 +27,18 @@ export function allChangedFilesSince(sha = 'HEAD') {
return Array.from(new Set([...diffFiles, ...untrackedFiles]));
}
/**
* A list of all staged files which have been modified.
*
* Only added, created and modified files are listed as others (deleted, renamed, etc) aren't
* changed or available as content to act upon.
*/
export function allStagedFiles() {
return gitOutputAsArray(`git diff --staged --name-only --diff-filter=ACM`);
}
export function allFiles() {
return gitOutputAsArray(`git ls-files`);
}