Skip to content

Commit

Permalink
handle incorrect path
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthkp committed Jun 28, 2019
1 parent 190da8a commit 6e5547b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const cosmiconfig = require('cosmiconfig')
const fs = require('fs')

const program = require('commander')
const { error } = require('prettycli')
Expand All @@ -23,8 +24,22 @@ program

let configFromCli

// add to the list of files to check at the 1st position
if (program.config) configPaths.unshift(program.config)
if (program.config) {
if (!fs.existsSync(program.config)) {
// throw error if file doesn't exist
error(
`Custom config file does not exist. Make sure the path is relative to the project root.
You can read about the configuration options here:
https://github.com/siddharthkp/bundlesize#configuration
`,
{ silent: true }
)
} else {
// add to the list of files to check at the 1st position
configPaths.unshift(program.config)
}
}

if (program.files) {
configFromCli = [
Expand Down

0 comments on commit 6e5547b

Please sign in to comment.