Skip to content

Commit 94b2961

Browse files
committed
fix: change to ignore scripts boolean instead of skip version scripts array.
1 parent 50670d8 commit 94b2961

9 files changed

+14
-41
lines changed

src/cli/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function main(args: string[]): Promise<void> {
4343
}
4444
}
4545

46-
function progress({ event, script, updatedFiles, skippedFiles, newVersion, skippedScripts }: VersionBumpProgress): void {
46+
function progress({ event, script, updatedFiles, skippedFiles, newVersion }: VersionBumpProgress): void {
4747
switch (event) {
4848
case ProgressEvent.FileUpdated:
4949
console.log(success, `Updated ${updatedFiles.pop()} to ${newVersion}`);
@@ -53,10 +53,6 @@ function progress({ event, script, updatedFiles, skippedFiles, newVersion, skipp
5353
console.log(info, `${skippedFiles.pop()} did not need to be updated`);
5454
break;
5555

56-
case ProgressEvent.ScriptSkipped:
57-
console.log(success, `Script skipped ${skippedScripts.pop()}`);
58-
break;
59-
6056
case ProgressEvent.GitCommit:
6157
console.log(success, "Git commit");
6258
break;

src/cli/parse-args.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function parseArgs(argv: string[]): ParsedArgs {
3131
{ name: "quiet", alias: "q", type: Boolean },
3232
{ name: "version", alias: "v", type: Boolean },
3333
{ name: "help", alias: "h", type: Boolean },
34-
{ name: "skip-version-scripts", type: String, multiple: true, defaultValue: []},
34+
{ name: "ignore-scripts", type: Boolean },
3535
{ name: "files", type: String, multiple: true, defaultOption: true },
3636
],
3737
{ argv }
@@ -49,7 +49,7 @@ export function parseArgs(argv: string[]): ParsedArgs {
4949
all: args.all as boolean,
5050
noVerify: args["no-verify"] as boolean,
5151
files: args.files as string[],
52-
skipVersionScripts: args["skip-version-scripts"] as string[],
52+
ignoreScripts: args["ignore-scripts"] as boolean,
5353
}
5454
};
5555

src/normalize-options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface NormalizedOptions {
5555
files: string[];
5656
cwd: string;
5757
interface: Interface;
58-
skipVersionScripts: string[];
58+
ignoreScripts: boolean;
5959
}
6060

6161
/**
@@ -132,9 +132,9 @@ export async function normalizeOptions(raw: VersionBumpOptions): Promise<Normali
132132
throw new Error("Cannot prompt for the version number because input or output has been disabled.");
133133
}
134134

135-
let skipVersionScripts = raw.skipVersionScripts as string[];
135+
let ignoreScripts = raw.ignoreScripts as boolean;
136136

137-
return { release, commit, tag, push, files, cwd, interface: ui, skipVersionScripts };
137+
return { release, commit, tag, push, files, cwd, interface: ui, ignoreScripts };
138138
}
139139

140140
/**

src/operation.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ interface OperationState {
1515
tagName: string;
1616
updatedFiles: string[];
1717
skippedFiles: string[];
18-
skippedScripts: string[];
1918
}
2019

2120
interface UpdateOperationState extends Partial<OperationState> {
@@ -44,7 +43,6 @@ export class Operation {
4443
tagName: "",
4544
updatedFiles: [],
4645
skippedFiles: [],
47-
skippedScripts: [],
4846
};
4947

5048
/**

src/run-npm-script.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ export async function runNpmScript(script: NpmScript, operation: Operation): Pro
1313
let { data: manifest } = await readJsonFile("package.json", cwd);
1414

1515
if (isManifest(manifest) && hasScript(manifest, script)) {
16-
if (shouldSkipScript(script, operation.options.skipVersionScripts)) {
17-
operation.update({ event: ProgressEvent.ScriptSkipped, skippedScripts: operation.state.skippedScripts.concat(script) });
18-
}
19-
else {
16+
if (!operation.options.ignoreScripts) {
2017
await ezSpawn.async("npm", ["run", script, "--silent"], { stdio: "inherit" });
2118
operation.update({ event: ProgressEvent.NpmScript, script });
2219
}
23-
2420
}
2521

2622
return operation;
@@ -38,10 +34,3 @@ function hasScript(manifest: Manifest, script: NpmScript): boolean {
3834

3935
return false;
4036
}
41-
42-
/**
43-
* Determines whether the specified script should be skipped.
44-
*/
45-
function shouldSkipScript(script: NpmScript, skipVersionScripts: string[]): boolean {
46-
return skipVersionScripts.includes(script);
47-
}

src/types/version-bump-options.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ export interface VersionBumpOptions {
9393
interface?: boolean | InterfaceOptions;
9494

9595
/**
96-
* The version scripts to be skipped
97-
* Options can be any or all of the following separated with space:
98-
* preversion, version and postversion
99-
* Defaults to []
96+
* Indicates whether to ignore version scripts.
97+
*
98+
* Defaults to `false`.
10099
*/
101-
skipVersionScripts?: string[];
100+
ignoreScripts?: boolean;
102101

103102
/**
104103
* A callback that is provides information about the progress of the `versionBump()` function.

src/types/version-bump-progress.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export const enum ProgressEvent {
1010
GitTag = "git tag",
1111
GitPush = "git push",
1212
NpmScript = "npm script",
13-
ScriptSkipped = "script skipped",
1413
}
1514

1615
/**

src/types/version-bump-results.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,4 @@ export interface VersionBumpResults {
4242
* The files that were not updated because they did not contain the old version number.
4343
*/
4444
skippedFiles: string[];
45-
46-
/**
47-
* The version scripts which were skipped because they were explicitly specified to be skipped.
48-
*/
49-
skippedScripts: string[];
5045
}

test/specs/api.spec.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ describe("versionBup() API", () => {
2727
commit: false,
2828
tag: false,
2929
updatedFiles: ["package.json"],
30-
skippedFiles: [],
31-
skippedScripts: []
30+
skippedFiles: []
3231
});
3332

3433
// The package.json file should have been updated
@@ -54,8 +53,7 @@ describe("versionBup() API", () => {
5453
commit: false,
5554
tag: false,
5655
updatedFiles: ["package.json"],
57-
skippedFiles: [],
58-
skippedScripts: []
56+
skippedFiles: []
5957
});
6058

6159
// The package.json file should have been updated
@@ -99,8 +97,7 @@ describe("versionBup() API", () => {
9997
"README.md",
10098
"subdir/deep/changelog.md"
10199
],
102-
skippedFiles: [],
103-
skippedScripts: []
100+
skippedFiles: []
104101
});
105102

106103
// The CWD should not have changed

0 commit comments

Comments
 (0)