Skip to content

Commit

Permalink
fix(config): Remove dependency on module-exists
Browse files Browse the repository at this point in the history
Using `module-exists` doesn't work with `yarn --pnp`. Using `fs.exists()` we get much better
gaurantees loading configs.
  • Loading branch information
tusharmath committed Feb 9, 2019
1 parent 30a4514 commit 6fb5b6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"@types/webpack": "^4.4.18",
"json-to-ts": "^1.5.4",
"minimist": "^1.2.0",
"module-exists": "^0.2.0",
"ramda": "^0.26.1",
"webpack": "^4.25.1"
},
Expand Down
6 changes: 3 additions & 3 deletions src/loadFileConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/**
* Created by tushar on 30/12/17.
*/
import moduleExists = require('module-exists')
import * as fs from 'fs'
import * as R from 'ramda'
import {configPaths, NonConfigEnv, ConfigTypes} from './configPaths'
import {configPaths, ConfigTypes, NonConfigEnv} from './configPaths'

export type Configurations<T> = {[key in keyof T]: any}

Expand All @@ -19,7 +19,7 @@ export const loadFileConfigs = <T extends NonConfigEnv>(
process: T
): Configurations<ConfigTypes> => {
const itar: any = R.mapObjIndexed(
R.ifElse(moduleExists, require, R.always({}))
R.ifElse(fs.existsSync, require, R.always({}))
)
return itar(configPaths(process))
}

0 comments on commit 6fb5b6f

Please sign in to comment.