Skip to content

Commit

Permalink
fix: validate number flags
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed May 3, 2024
1 parent 0a480d2 commit 878b945
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/validateOptions.js
Expand Up @@ -2,6 +2,7 @@ const defaults = require('lodash/defaults')

const clientMethods = ['getUrl', 'config']
const booleanFlags = ['assets', 'raw', 'compress', 'drafts']
const numberFlags = ['assetConcurrency']
const exportDefaults = {
compress: true,
drafts: true,
Expand Down Expand Up @@ -42,6 +43,12 @@ function validateOptions(opts) {
}
})

numberFlags.forEach((flag) => {
if (typeof options[flag] !== 'undefined' && typeof options[flag] !== 'number') {
throw new Error(`Flag ${flag} must be a number if specified`)
}
})

if (!options.outputPath) {
throw new Error('outputPath must be specified (- for stdout)')
}
Expand Down

0 comments on commit 878b945

Please sign in to comment.