Skip to content

Commit

Permalink
fixup! feat(ng-dev/format): add staged-re command
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz committed Feb 14, 2022
1 parent 4d7cd4f commit 4bd3efd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions github-actions/commit-message-based-labels/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49451,8 +49451,8 @@ var require_git_client = __commonJS({
allStagedFiles() {
return gitOutputAsArray(this.runGraceful(["diff", "--name-only", "--diff-filter=ACM", "--staged"]));
}
stageFiles(files) {
return gitOutputAsArray(this.runGraceful(["add", files.join(" ")]));
stageFiles(files, options = {}) {
return this.runGraceful(["add", ...files], options);
}
allFiles() {
return gitOutputAsArray(this.runGraceful(["ls-files"]));
Expand Down
4 changes: 2 additions & 2 deletions github-actions/slash-commands/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55125,8 +55125,8 @@ var require_git_client = __commonJS({
allStagedFiles() {
return gitOutputAsArray(this.runGraceful(["diff", "--name-only", "--diff-filter=ACM", "--staged"]));
}
stageFiles(files) {
return gitOutputAsArray(this.runGraceful(["add", files.join(" ")]));
stageFiles(files, options = {}) {
return this.runGraceful(["add", ...files], options);
}
allFiles() {
return gitOutputAsArray(this.runGraceful(["ls-files"]));
Expand Down
11 changes: 3 additions & 8 deletions ng-dev/format/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,12 @@ export function buildFormatParser(localYargs: yargs.Argv) {
.command(
'staged',
'Run the formatter on all staged files',
(args) =>
args.options('add', {
type: 'boolean',
description: 'Add the potentially formatted files back to the staging area',
conflicts: 'check',
}),
async ({check, add}) => {
(args) => args,
async ({check}) => {
const executionCmd = check ? checkFiles : formatFiles;
const allStagedFiles = GitClient.get().allStagedFiles();
process.exitCode = await executionCmd(allStagedFiles);
if (!check && add && process.exitCode === 0) {
if (!check && process.exitCode === 0) {
GitClient.get().stageFiles(allStagedFiles);
}
},
Expand Down
4 changes: 2 additions & 2 deletions ng-dev/utils/git/git-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ export class GitClient {
}

/** Adds the provided files to the staging area. */
stageFiles(files: string[]) {
return gitOutputAsArray(this.runGraceful(['add', files.join(' ')]));
stageFiles(files: string[], options: GitCommandRunOptions = {}): SpawnSyncReturns<string> {
return this.runGraceful(['add', ...files], options);
}

/** Retrieve a list of all files tracked in the repository. */
Expand Down
4 changes: 2 additions & 2 deletions tools/local-actions/changelog/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46552,8 +46552,8 @@ var require_git_client = __commonJS({
allStagedFiles() {
return gitOutputAsArray(this.runGraceful(["diff", "--name-only", "--diff-filter=ACM", "--staged"]));
}
stageFiles(files) {
return gitOutputAsArray(this.runGraceful(["add", files.join(" ")]));
stageFiles(files, options = {}) {
return this.runGraceful(["add", ...files], options);
}
allFiles() {
return gitOutputAsArray(this.runGraceful(["ls-files"]));
Expand Down

0 comments on commit 4bd3efd

Please sign in to comment.