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:

committed by
Andrew Kushnir

parent
a6292faa97
commit
28534d83ee
@ -7,7 +7,7 @@
|
||||
*/
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
import {allChangedFilesSince, allFiles} from '../utils/repo-files';
|
||||
import {allChangedFilesSince, allFiles, allStagedFiles} from '../utils/repo-files';
|
||||
|
||||
import {checkFiles, formatFiles} from './format';
|
||||
|
||||
@ -34,6 +34,12 @@ export function buildFormatParser(localYargs: yargs.Argv) {
|
||||
const executionCmd = check ? checkFiles : formatFiles;
|
||||
executionCmd(allChangedFilesSince(sha));
|
||||
})
|
||||
.command(
|
||||
'staged', 'Run the formatter on all staged files', {},
|
||||
({check}) => {
|
||||
const executionCmd = check ? checkFiles : formatFiles;
|
||||
executionCmd(allStagedFiles());
|
||||
})
|
||||
.command('files <files..>', 'Run the formatter on provided files', {}, ({check, files}) => {
|
||||
const executionCmd = check ? checkFiles : formatFiles;
|
||||
executionCmd(files);
|
||||
|
Reference in New Issue
Block a user