Skip to content

Commit b699a1e

Browse files
dgp1130alan-agius4
authored andcommitted
ci: parse boolean flags from string inputs
Flag arguments provided by minimist are always strings. Both `--branchCheck` and `--versionCheck` failed to take this into account and were incorrectly typed as a result. Now boolean flags are parsed into actual boolean types which can be used more intuitively.
1 parent 70c82a1 commit b699a1e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

scripts/publish.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export interface PublishArgs {
2020
registry?: string;
2121
}
2222

23-
2423
function _exec(command: string, args: string[], opts: { cwd?: string }, logger: logging.Logger) {
2524
if (process.platform.startsWith('win')) {
2625
args.unshift('/c', command);
@@ -52,7 +51,8 @@ function _branchCheck(args: PublishArgs, logger: logging.Logger) {
5251
case 'master':
5352
if (args.tag !== 'next') {
5453
throw new Error(tags.oneLine`
55-
Releasing from master requires a next tag. Use --branchCheck=false to skip this check.
54+
Releasing from master requires a next tag. Use --no-branchCheck to
55+
skip this check.
5656
`);
5757
}
5858
}
@@ -75,7 +75,7 @@ function _versionCheck(args: PublishArgs, logger: logging.Logger) {
7575
if (betaOrRc && args.tag !== 'next') {
7676
throw new Error(tags.oneLine`
7777
Releasing version ${JSON.stringify(version)} requires a next tag.
78-
Use --versionCheck=false to skip this check.
78+
Use --no-versionCheck to skip this check.
7979
`);
8080
}
8181

@@ -90,10 +90,11 @@ function _versionCheck(args: PublishArgs, logger: logging.Logger) {
9090
}
9191

9292
export default async function (args: PublishArgs, logger: logging.Logger) {
93-
if (args.branchCheck === undefined || args.branchCheck === true) {
93+
if (args.branchCheck ?? true) {
9494
_branchCheck(args, logger);
9595
}
96-
if (args.versionCheck === undefined || args.versionCheck === true) {
96+
97+
if (args.versionCheck ?? true) {
9798
_versionCheck(args, logger);
9899
}
99100

tests/legacy-cli/e2e/setup/010-local-publish.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export default async function() {
88
'admin',
99
'--',
1010
'publish',
11-
'--versionCheck=false',
12-
'--branchCheck=false',
11+
'--no-versionCheck',
12+
'--no-branchCheck',
1313
'--registry=http://localhost:4873',
1414
];
1515

0 commit comments

Comments
 (0)