Skip to content

Commit

Permalink
fix(load-cfg): use fs-extra to read json sync instead of JSON.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Aug 29, 2018
1 parent 9b07d27 commit 04d1e1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/load-cfg/package.json
Expand Up @@ -24,7 +24,8 @@
"dependencies": {
"deepmerge": "^2.1.1",
"esm": "^3.0.80",
"find-up": "^3.0.0"
"find-up": "^3.0.0",
"fs-extra": "^7.0.0"
},
"devDependencies": {
"@types/find-up": "^2.1.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/load-cfg/src/index.ts
@@ -1,4 +1,4 @@
import * as fs from 'fs'
import * as fs from 'fs-extra'
import * as path from 'path'
import findup from 'find-up'
import merge from 'deepmerge'
Expand Down Expand Up @@ -27,11 +27,11 @@ export const loadFile = (filepath: string, noCache?: boolean) => {
const required = require(filepath)
file = required.default || required
} else {
file = JSON.parse(fs.readFileSync(filepath, 'utf-8'))
file = fs.readJsonSync(filepath, { encoding: 'utf-8' })
}
} catch (err) {
console.warn('There was an error loading your config:')
throw err
console.warn('There was an error loading your config:\n')
console.warn(err)
}

return file
Expand Down

0 comments on commit 04d1e1a

Please sign in to comment.