Skip to content

Commit 2db6aca

Browse files
committed
set exit code to 1 when printing warnings
1 parent ed6d72e commit 2db6aca

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/bin/hsm.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const colourV = chalk.rgb(0xFF, 0x00, 0xEC)
8585
const colourW = chalk.rgb(0xFF, 0x96, 0xE0)
8686

8787
if (process.version.startsWith(`v21.`)) {
88+
process.exitCode = 1
89+
8890
console.warn(colourF(`\
8991
${chalk.bold(`Warning:`)} Support for Node.js 21 will be dropped in the next minor version of HSM
9092
Your current version of Node.js is ${chalk.bold(process.version)}
@@ -116,6 +118,8 @@ switch (commands[0]) {
116118
const noMinifyOption = popOption(`no-minify`, `skip-minify`)
117119

118120
if (noMinifyOption && noMinifyOption.name != `no-minify`) {
121+
process.exitCode = 1
122+
119123
console.warn(colourF(`\
120124
${chalk.bold(`Warning:`)} ${formatOption(noMinifyOption.name)} is deprecated and will be removed in the next minor
121125
release of HSM
@@ -217,6 +221,9 @@ ${chalk.bold(`Warning:`)} ${formatOption(noMinifyOption.name)} is deprecated and
217221

218222
const timeTook = performance.now() - timeStart
219223

224+
if (warnings.length)
225+
process.exitCode = 1
226+
220227
for (const { message } of warnings)
221228
console.warn(colourF(`${chalk.bold(`Warning:`)} ${message}`))
222229

@@ -333,6 +340,8 @@ ${colourN(`--hackmud-path`)}=${colourB(`<path>`)} option or ${colourN(`HSM_HACKM
333340
popOption(`dts-path`, `type-declaration-path`, `type-declaration`, `dts`, `gen-types`)
334341

335342
if (dtsPathOption && dtsPathOption.name != `dts-path` && dtsPathOption.name != `type-declaration-path`) {
343+
process.exitCode = 1
344+
336345
console.warn(colourF(`\
337346
${chalk.bold(`Warning:`)} ${formatOption(dtsPathOption.name)} is deprecated and will be removed in the
338347
next minor release of HSM
@@ -397,6 +406,7 @@ ${chalk.bold(`Warning:`)} ${formatOption(dtsPathOption.name)} is deprecated and
397406
case `emit-dts`: {
398407
if (commands[0] != `emit-dts` && commands[0] != `gen-dts`) {
399408
warnedDeprecatedEmitDtsAlias = true
409+
process.exitCode = 1
400410

401411
console.warn(colourF(`\
402412
${chalk.bold(`Warning:`)} ${colourC(`hsm`)} ${colourL(commands[0])} is deprecated and will be removed
@@ -559,6 +569,8 @@ ${colourN(`--root-folder-path`)}
559569
case `gen-types`:
560570
case `emit-dts`: {
561571
if (!warnedDeprecatedEmitDtsAlias && commands[0] != `emit-dts` && commands[0] != `gen-dts`) {
572+
process.exitCode = 1
573+
562574
console.warn(colourF(`\
563575
${chalk.bold(`Warning:`)} ${colourC(`hsm`)} ${colourL(commands[0])} is deprecated and will be removed
564576
in the next minor release of HSM
@@ -620,6 +632,9 @@ function logInfo({ path, users, characterCount, error, warnings }: Info, hackmud
620632
return
621633
}
622634

635+
if (warnings.length)
636+
process.exitCode = 1
637+
623638
for (const warning of warnings)
624639
console.warn(colourF(`${chalk.bold(`Warning:`)} ${warning.message}`))
625640

0 commit comments

Comments
 (0)