Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/bin/hsm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type OptionValue = boolean | string

const options = new Map<string, OptionValue>
const commands: string[] = []
let didParseOption = false
let didParseOptionAfterCommand = false

for (const argument of process.argv.slice(2)) {
if (argument[0] == `-`) {
Expand All @@ -48,8 +50,15 @@ for (const argument of process.argv.slice(2)) {
for (const option of key!.slice(1))
options.set(option, value)
}
} else

didParseOption = true
} else {
if (didParseOption) {
didParseOptionAfterCommand = true
}

commands.push(argument)
}
}

const pushModule = import(`../push`)
Expand Down Expand Up @@ -83,6 +92,15 @@ const userColours = new AutoMap<string, string>(user => {

const log = (message: string) => console.log(colourS(message))

if (didParseOptionAfterCommand) {
process.exitCode = 1

console.warn(colourF(`\
${chalk.bold(`Warning:`)} Options should come after commands when calling the script.
This warning will become an error in the next minor version of HSM.`
))
}

if (process.version.startsWith(`v21.`)) {
process.exitCode = 1

Expand Down