Comparing version 0.7.0 to 0.7.1
20
index.js
@@ -6,2 +6,3 @@ "use strict"; | ||
const dirname = require("path").dirname; | ||
const homedir = require("os").homedir; | ||
const resolvePath = require("path").resolve; | ||
@@ -21,5 +22,11 @@ | ||
const RELATIVE_PATH_RE = /^\.{1,2}[/\\]/; | ||
function resolveRelativePaths(value, base) { | ||
if (typeof value === "string" && RELATIVE_PATH_RE.test(value)) { | ||
return Promise.resolve(resolvePath(base, value)); | ||
function resolvePaths(value, base) { | ||
if (typeof value === "string") { | ||
return Promise.resolve( | ||
value[0] === "~" && (value[1] === "/" || value[1] === "\\") | ||
? homedir() + value.slice(1) | ||
: RELATIVE_PATH_RE.test(value) | ||
? resolvePath(base, value) | ||
: value | ||
); | ||
} | ||
@@ -29,3 +36,3 @@ | ||
return pMap(Object.keys(value), key => | ||
resolveRelativePaths(value[key], base).then(resolved => { | ||
resolvePaths(value[key], base).then(resolved => { | ||
value[key] = resolved; | ||
@@ -59,6 +66,7 @@ }) | ||
files = flatten(files); | ||
files.forEach(_ => debug(_.path)); | ||
return pMap(files, file => { | ||
try { | ||
return resolveRelativePaths(unserialize(file), dirname(file.path)); | ||
const data = unserialize(file); | ||
debug(file.path); | ||
return resolvePaths(data, dirname(file.path)); | ||
} catch (error) { | ||
@@ -65,0 +73,0 @@ if (!(ignoreUnknownFormats && error instanceof UnknownFormatError)) { |
{ | ||
"name": "app-conf", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"license": "ISC", | ||
@@ -29,19 +29,19 @@ "author": "Julien Fontanet <julien.fontanet@isonoe.net> (http://julien.isonoe.net/)", | ||
"make-error": "^1.3.5", | ||
"promise-toolbox": "^0.12.1", | ||
"promise-toolbox": "^0.14.0", | ||
"xdg-basedir": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.9.0", | ||
"eslint-config-prettier": "^4.2.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint": "^6.5.1", | ||
"eslint-config-prettier": "^6.4.0", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-node": "^9.0.1", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"husky": "^2.3.0", | ||
"husky": "^3.0.9", | ||
"jest": "^24.8.0", | ||
"lint-staged": "^8.1.0", | ||
"lint-staged": "^9.4.2", | ||
"mock-fs": "^4.7.0", | ||
"prettier": "^1.15.2", | ||
"rimraf": "^2.6.2" | ||
"rimraf": "^3.0.0" | ||
}, | ||
@@ -48,0 +48,0 @@ "scripts": { |
@@ -1,3 +0,5 @@ | ||
# app-conf [![Build Status](https://travis-ci.org/julien-f/nodejs-app-conf.png?branch=master)](https://travis-ci.org/julien-f/nodejs-app-conf) | ||
# app-conf | ||
[![Package Version](https://badgen.net/npm/v/app-conf)](https://npmjs.org/package/app-conf) [![Build Status](https://travis-ci.org/julien-f/nodejs-app-conf.png?branch=master)](https://travis-ci.org/julien-f/nodejs-app-conf) [![PackagePhobia](https://badgen.net/packagephobia/install/app-conf)](https://packagephobia.now.sh/result?p=app-conf) [![Latest Commit](https://badgen.net/github/last-commit/julien-f/nodejs-app-conf)](https://github.com/julien-f/nodejs-app-conf/commits/master) | ||
## Usage | ||
@@ -19,11 +21,17 @@ | ||
- `config.*` in the project directory; | ||
- `/etc/my-application/config.*`; | ||
- `~/.config/my-application/config.*`; | ||
- `/.my-application.*` down to `./.my-application.*` in the current | ||
working directory. | ||
1. **vendor**: `config.*` in the application directory; | ||
1. **global**: `/etc/my-application/config.*`; | ||
1. **user**: `~/.config/my-application/config.*`; | ||
1. **local**: `/.my-application.*` down to `./.my-application.*` in the current | ||
working directory; | ||
> Note: the **local** config is relative to the current working directory and | ||
> only makes sense for CLIs. | ||
Relative paths, string values starting by `./` or `../`, are automatically | ||
resolved from the config file directory. | ||
Paths relative to the home directory, string values starting by `~/`, are also | ||
automatically resolved. | ||
JSON format is supported natively but you may install the following | ||
@@ -30,0 +38,0 @@ packages to have additional features: |
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
12410
268
59
+ Addedpromise-toolbox@0.14.0(transitive)
- Removedpromise-toolbox@0.12.1(transitive)
Updatedpromise-toolbox@^0.14.0