Comparing version 2.0.0 to 3.0.0
@@ -11,4 +11,5 @@ 'use strict'; | ||
module.exports = function (appname, startDir) { | ||
const dirPaths = internals.dirPaths(startDir || process.cwd(), `.${appname}rc`); | ||
const homePaths = internals.homePaths(appname); | ||
const filename = `.${appname}rc.js`; | ||
const dirPaths = internals.dirPaths(startDir || process.cwd(), filename); | ||
const homePaths = internals.homePaths(filename); | ||
@@ -56,12 +57,8 @@ // Didn't find in the parent folders, try at home next | ||
internals.homePaths = function (appname) { | ||
internals.homePaths = function (filename) { | ||
const home = process.env.USERPROFILE || process.env.HOME; | ||
return [ | ||
Path.join(home, `.${appname}rc`), | ||
Path.join(home, `.${appname}`, 'config'), | ||
Path.join(home, '.config', appname), | ||
Path.join(home, '.config', appname, 'config'), | ||
Path.join('/etc', `${appname}rc`), | ||
Path.join('/etc', `${appname}.rc`) | ||
Path.join(home, filename), | ||
Path.join(home, '.config', filename) | ||
]; | ||
}; |
{ | ||
"name": "find-rc", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Find a .rc file given a name", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -7,2 +7,5 @@ # `npm install find-rc` | ||
The rc file is assumed to be written in JavaScript, therefore the filename must | ||
be `.${app}rc.js`. If your app is named 'lab' then the rc file must be named | ||
`.labrc.js`. | ||
@@ -13,8 +16,4 @@ Here is the order that folders will be searched: | ||
2. Parent of current directory, until the root folder is encountered | ||
3. $HOME/.${apprc} | ||
4. $HOME/.${app}/config | ||
5. $HOME/.config/${app} | ||
6. $HOME/.config/${app}/config | ||
7. /etc/${app}rc | ||
8. /etc/${app}.rc | ||
3. $HOME/.${app}rc.js | ||
4. $HOME/.config/.${app}rc.js | ||
@@ -24,3 +23,3 @@ | ||
- `appname` - name of file you are looking for. Example: `lab`. It will be formatted with `.{appname}rc` | ||
- `appname` - name of file you are looking for. Example: `lab`. It will be formatted as `.{appname}rc.js` | ||
- `startDir` - (optional) directory to start looking for the file. Defaults to `process.cwd` | ||
@@ -27,0 +26,0 @@ |
@@ -16,3 +16,3 @@ 'use strict'; | ||
expect(filePath).to.exist(); | ||
expect(filePath).to.contain('.findrc'); | ||
expect(filePath).to.contain('.findrc.js'); | ||
done(); | ||
@@ -25,3 +25,3 @@ }); | ||
expect(filePath).to.exist(); | ||
expect(filePath).to.contain('.findrc'); | ||
expect(filePath).to.contain('.findrc.js'); | ||
done(); | ||
@@ -28,0 +28,0 @@ }); |
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
5949
75
35