Skip to content

Commit

Permalink
Refactor to improve internal types
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMurphy committed Dec 31, 2021
1 parent 2ce8180 commit 6ef18dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export function args(cliConfig) {
// @ts-expect-error: Close enough.
config = options(process.argv.slice(2), cliConfig)
} catch (error) {
return fail(error, true)
const exception = /** @type {Error} */ (error)
return fail(exception, true)
}

if (config.help) {
Expand Down
3 changes: 2 additions & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,12 @@ function parseConfig(value, cache) {
try {
flags = toCamelCase(parseJSON(value))
} catch (error) {
const exception = /** @type {Error} */ (error)
throw fault(
'Cannot parse `%s` as JSON: %s',
value,
// Fix position
error.message.replace(/at(?= position)/, 'around')
exception.message.replace(/at(?= position)/, 'around')
)
}

Expand Down

0 comments on commit 6ef18dd

Please sign in to comment.