Comparing version 1.1.0 to 2.0.0
17
cli.js
@@ -22,14 +22,7 @@ #!/usr/bin/env node | ||
stdout.write( | ||
inspect( | ||
await load(appName, { | ||
appDir, | ||
// ignore vendor config (not relevant for this CLI) | ||
entries: | ||
appDir === undefined ? ["system", "global", "local"] : undefined, | ||
ignoreUnknownFormats: true, | ||
}), | ||
{ colors: true, depth: Infinity, sorted: true } | ||
) | ||
inspect(await load(appName, { appDir, ignoreUnknownFormats: true }), { | ||
colors: true, | ||
depth: Infinity, | ||
sorted: true, | ||
}) | ||
); | ||
@@ -36,0 +29,0 @@ stdout.write("\n"); |
@@ -47,3 +47,3 @@ "use strict"; | ||
dir: (opts) => opts.appDir, | ||
read: (_, dir) => pMap(glob(j(dir, "config.*")), readFile), | ||
read: (_, dir) => dir && pMap(glob(j(dir, "config.*")), readFile), | ||
}, | ||
@@ -65,4 +65,3 @@ | ||
}, | ||
read: (_, dir) => | ||
dir === undefined ? [] : pMap(glob(j(dir, "config.*")), readFile), | ||
read: (_, dir) => dir && pMap(glob(j(dir, "config.*")), readFile), | ||
}, | ||
@@ -69,0 +68,0 @@ |
22
index.js
@@ -46,16 +46,5 @@ "use strict"; | ||
// Does not work properly in many cases (e.g. with pnpm) | ||
// | ||
// It's better for the user to pass an `appDir` option but we need to | ||
// keep this for compatibility. | ||
const DEFAULT_APP_DIR = dirname(dirname(__dirname)); | ||
function load( | ||
appName, | ||
{ | ||
appDir = DEFAULT_APP_DIR, | ||
defaults, | ||
entries: whitelist, | ||
ignoreUnknownFormats = false, | ||
} = {} | ||
{ appDir, defaults, entries: whitelist, ignoreUnknownFormats = false } = {} | ||
) { | ||
@@ -74,3 +63,3 @@ const useWhitelist = whitelist !== undefined; | ||
const dir = typeof dirFn === "function" ? dirFn(entryOpts) : dirFn; | ||
return entry.read(entryOpts, dir); | ||
return entry.read(entryOpts, dir) || []; | ||
}) | ||
@@ -106,9 +95,4 @@ .then((files) => { | ||
return new Promise((resolve, reject) => { | ||
const { appDir } = opts; | ||
if (appDir === undefined) { | ||
throw new TypeError("appDir must be defined"); | ||
} | ||
const dirs = []; | ||
const entryOpts = { appName, appDir }; | ||
const entryOpts = { appName, appDir: opts.appDir }; | ||
entries.forEach((entry) => { | ||
@@ -115,0 +99,0 @@ const dirFn = entry.dir; |
{ | ||
"name": "app-conf", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"license": "ISC", | ||
@@ -43,29 +43,23 @@ "author": "Julien Fontanet <julien.fontanet@isonoe.net> (http://julien.isonoe.net/)", | ||
"husky": "^4", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10", | ||
"mock-fs": "^5.1.2", | ||
"prettier": "^2.2.1", | ||
"rimraf": "^3.0.0" | ||
"rimraf": "^3.0.0", | ||
"tap": "^15.1.6" | ||
}, | ||
"scripts": { | ||
"dev-test": "jest --bail --watch", | ||
"test": "jest" | ||
"dev-test": "tap --no-check-coverage --watch", | ||
"test": "tap --no-check-coverage" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
"pre-commit": "lint-staged && npm run test" | ||
} | ||
}, | ||
"jest": { | ||
"collectCoverage": true, | ||
"testEnvironment": "node", | ||
"testRegex": "\\.spec\\.js$" | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"prettier --write", | ||
"eslint --ignore-pattern '!*'", | ||
"jest --findRelatedTests --passWithNoTests" | ||
"eslint --ignore-pattern '!*'" | ||
] | ||
} | ||
} |
@@ -24,2 +24,4 @@ # app-conf | ||
// this is the directory where the vendor conf is stored | ||
// | ||
// vendor config will not be loaded if not defined | ||
appDir: __dirname, | ||
@@ -65,5 +67,2 @@ | ||
{ | ||
// contrary to `load`, this option is required | ||
appDir: __dirname, | ||
// contrary to `load`, this is part of the options | ||
@@ -70,0 +69,0 @@ appName: "my-application", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15954
348
114