mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Initial commit
This commit is contained in:
39
node_modules/cosmiconfig/CHANGELOG.md
generated
vendored
Normal file
39
node_modules/cosmiconfig/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# Changelog
|
||||
|
||||
## 2.1.1
|
||||
|
||||
- Fixed: swapped `graceful-fs` for regular `fs`, fixing a garbage collection problem.
|
||||
|
||||
## 2.1.0
|
||||
|
||||
- Added: Node 0.12 support.
|
||||
|
||||
## 2.0.2
|
||||
|
||||
- Fixed: Node version specified in `package.json`.
|
||||
|
||||
## 2.0.1
|
||||
|
||||
- Fixed: no more infinite loop in Windows.
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- Changed: module now creates cosmiconfig instances with `load` methods (see README).
|
||||
- Added: caching (enabled by the change above).
|
||||
- Removed: support for Node versions <4.
|
||||
|
||||
## 1.1.0
|
||||
|
||||
- Add `rcExtensions` option.
|
||||
|
||||
## 1.0.2
|
||||
|
||||
- Fix handling of `require()`'s within JS module configs.
|
||||
|
||||
## 1.0.1
|
||||
|
||||
- Switch Promise implementation to pinkie-promise.
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- Initial release.
|
22
node_modules/cosmiconfig/LICENSE
generated
vendored
Normal file
22
node_modules/cosmiconfig/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 David Clark
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
226
node_modules/cosmiconfig/README.md
generated
vendored
Normal file
226
node_modules/cosmiconfig/README.md
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
# cosmiconfig
|
||||
|
||||
[](https://travis-ci.org/davidtheclark/cosmiconfig) [](https://ci.appveyor.com/project/davidtheclark/cosmiconfig/branch/master)
|
||||
|
||||
Find and load a configuration object from
|
||||
- a `package.json` property (anywhere down the file tree)
|
||||
- a JSON or YAML "rc file" (anywhere down the file tree)
|
||||
- a `.config.js` CommonJS module (anywhere down the file tree)
|
||||
- a CLI `--config` argument
|
||||
|
||||
For example, if your module's name is "soursocks," cosmiconfig will search out configuration in the following places:
|
||||
- a `soursocks` property in `package.json` (anywhere down the file tree)
|
||||
- a `.soursocksrc` file in JSON or YAML format (anywhere down the file tree)
|
||||
- a `soursocks.config.js` file exporting a JS object (anywhere down the file tree)
|
||||
- a CLI `--config` argument
|
||||
|
||||
cosmiconfig continues to search in these places all the way down the file tree until it finds acceptable configuration (or hits the home directory). And it does all this asynchronously, so it shouldn't get in your way.
|
||||
|
||||
Additionally, all of these search locations are configurable: you can customize filenames or turn off any location.
|
||||
|
||||
You can also look for rc files with extensions, e.g. `.soursocksrc.json` or `.soursocksrc.yaml`.
|
||||
You may like extensions on your rc files because you'll get syntax highlighting and linting in text editors.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install cosmiconfig
|
||||
```
|
||||
|
||||
Tested in Node 0.12+.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var cosmiconfig = require('cosmiconfig');
|
||||
|
||||
var explorer = cosmiconfig(yourModuleName[, options]);
|
||||
|
||||
explorer.load(yourSearchPath)
|
||||
.then((result) => {
|
||||
// result.config is the parsed configuration object
|
||||
// result.filepath is the path to the config file that was found
|
||||
})
|
||||
.catch((parsingError) => {
|
||||
// do something constructive
|
||||
});
|
||||
```
|
||||
|
||||
The function `cosmiconfig()` searches for a configuration object and returns a Promise,
|
||||
which resolves with an object containing the information you're looking for.
|
||||
|
||||
So let's say `var yourModuleName = 'goldengrahams'` — here's how cosmiconfig will work:
|
||||
|
||||
- Starting from `process.cwd()` (or some other directory defined by the `searchPath` argument to `load()`), it looks for configuration objects in three places, in this order:
|
||||
1. A `goldengrahams` property in a `package.json` file (or some other property defined by `options.packageProp`);
|
||||
2. A `.goldengrahamsrc` file with JSON or YAML syntax (or some other filename defined by `options.rc`);
|
||||
3. A `goldengrahams.config.js` JS file exporting the object (or some other filename defined by `options.js`).
|
||||
- If none of those searches reveal a configuration object, it moves down one directory and tries again. So the search continues in `./`, `../`, `../../`, `../../../`, etc., checking those three locations in each directory.
|
||||
- It continues searching until it arrives at your home directory (or some other directory defined by `options.stopDir`).
|
||||
- If at any point a parseable configuration is found, the `cosmiconfig()` Promise resolves with its result object.
|
||||
- If no configuration object is found, the `cosmiconfig()` Promise resolves with `null`.
|
||||
- If a configuration object is found *but is malformed* (causing a parsing error), the `cosmiconfig()` Promise rejects and shares that error (so you should `.catch()` it).
|
||||
|
||||
All this searching can be short-circuited by passing `options.configPath` or a `--config` CLI argument to specify a file.
|
||||
cosmiconfig will read that file and try parsing it as JSON, YAML, or JS.
|
||||
|
||||
## Caching
|
||||
|
||||
As of v2, cosmiconfig uses a few caches to reduce the need for repetitious reading of the filesystem. Every new cosmiconfig instance (created with `cosmiconfig()`) has its own caches.
|
||||
|
||||
To avoid or work around caching, you can
|
||||
- create separate instances of cosmiconfig, or
|
||||
- set `cache: false` in your options.
|
||||
- use the cache clearing methods documented below.
|
||||
|
||||
## API
|
||||
|
||||
### `var explorer = cosmiconfig(moduleName[, options])`
|
||||
|
||||
Creates a cosmiconfig instance (i.e. explorer) configured according to the arguments, and initializes its caches.
|
||||
|
||||
#### moduleName
|
||||
|
||||
Type: `string`
|
||||
|
||||
You module name. This is used to create the default filenames that cosmiconfig will look for.
|
||||
|
||||
#### Options
|
||||
|
||||
##### packageProp
|
||||
|
||||
Type: `string` or `false`
|
||||
Default: `'[moduleName]'`
|
||||
|
||||
Name of the property in `package.json` to look for.
|
||||
|
||||
If `false`, cosmiconfig will not look in `package.json` files.
|
||||
|
||||
##### rc
|
||||
|
||||
Type: `string` or `false`
|
||||
Default: `'.[moduleName]rc'`
|
||||
|
||||
Name of the "rc file" to look for, which can be formatted as JSON or YAML.
|
||||
|
||||
If `false`, cosmiconfig will not look for an rc file.
|
||||
|
||||
If `rcExtensions: true`, the rc file can also have extensions that specify the syntax, e.g. `.[moduleName]rc.json`.
|
||||
You may like extensions on your rc files because you'll get syntax highlighting and linting in text editors.
|
||||
Also, with `rcExtensions: true`, you can use JS modules as rc files, e.g. `.[moduleName]rc.js`.
|
||||
|
||||
##### js
|
||||
|
||||
Type: `string` or `false`
|
||||
Default: `'[moduleName].config.js'`
|
||||
|
||||
Name of a JS file to look for, which must export the configuration object.
|
||||
|
||||
If `false`, cosmiconfig will not look for a JS file.
|
||||
|
||||
##### argv
|
||||
|
||||
Type: `string` or `false`
|
||||
Default: `'config'`
|
||||
|
||||
Name of a `process.argv` argument to look for, whose value should be the path to a configuration file.
|
||||
cosmiconfig will read the file and try to parse it as JSON, YAML, or JS.
|
||||
By default, cosmiconfig looks for `--config`.
|
||||
|
||||
If `false`, cosmiconfig will not look for any `process.argv` arguments.
|
||||
|
||||
##### rcStrictJson
|
||||
|
||||
Type: `boolean`
|
||||
Default: `false`
|
||||
|
||||
If `true`, cosmiconfig will expect rc files to be strict JSON. No YAML permitted, and no sloppy JSON.
|
||||
|
||||
By default, rc files are parsed with [js-yaml](https://github.com/nodeca/js-yaml), which is
|
||||
more permissive with punctuation than standard strict JSON.
|
||||
|
||||
##### rcExtensions
|
||||
|
||||
Type: `boolean`
|
||||
Default: `false`
|
||||
|
||||
If `true`, cosmiconfig will look for rc files with extensions, in addition to rc files without.
|
||||
|
||||
This adds a few steps to the search process.
|
||||
Instead of *just* looking for `.goldengrahamsrc` (no extension), it will also look for the following, in this order:
|
||||
|
||||
- `.goldengrahamsrc.json`
|
||||
- `.goldengrahamsrc.yaml`
|
||||
- `.goldengrahamsrc.yml`
|
||||
- `.goldengrahamsrc.js`
|
||||
|
||||
##### stopDir
|
||||
|
||||
Type: `string`
|
||||
Default: Absolute path to your home directory
|
||||
|
||||
Directory where the search will stop.
|
||||
|
||||
##### cache
|
||||
|
||||
Type: `boolean`
|
||||
Default: `true`
|
||||
|
||||
If `false`, no caches will be used.
|
||||
|
||||
##### transform
|
||||
|
||||
Type: `Function` returning a Promise
|
||||
|
||||
A function that transforms the parsed configuration. Receives the result object with `config` and `filepath` properties, and must return a Promise that resolves with the transformed result.
|
||||
|
||||
The reason you might use this option instead of simply applying your transform function some other way is that *the transformed result will be cached*. If your transformation involves additional filesystem I/O or other potentially slow processing, you can use this option to avoid repeating those steps every time a given configuration is loaded.
|
||||
|
||||
### Instance methods (on `explorer`)
|
||||
|
||||
#### `load([searchPath, configPath])`
|
||||
|
||||
Find and load a configuration file. Returns `null` if nothing is found, or an object with two properties:
|
||||
- `config`: The loaded and parsed configuration.
|
||||
- `filepath`: The filepath where this configuration was found.
|
||||
|
||||
You should provide *either* `searchPath` *or* `configPath`. Use `configPath` if you know the path of the configuration file you want to load. Otherwise, use `searchPath`.
|
||||
|
||||
```js
|
||||
explorer.load('start/search/here');
|
||||
explorer.load('start/search/at/this/file.css');
|
||||
|
||||
explorer.load(null, 'load/this/file.json');
|
||||
```
|
||||
|
||||
If you provide `searchPath`, cosmiconfig will start its search at `searchPath` and continue to search up the file tree, as documented above.
|
||||
|
||||
If you provide `configPath` (i.e. you already know where the configuration is that you want to load), cosmiconfig will try to read and parse that file.
|
||||
|
||||
#### `clearFileCache()`
|
||||
|
||||
Clears the cache used when you provide a `configPath` argument to `load`.
|
||||
|
||||
#### `clearDirectoryCache()`
|
||||
|
||||
Clears the cache used when you provide a `searchPath` argument to `load`.
|
||||
|
||||
#### `clearCaches()`
|
||||
|
||||
Performs both `clearFileCache()` and `clearDirectoryCache()`.
|
||||
|
||||
## Differences from [rc](https://github.com/dominictarr/rc)
|
||||
|
||||
[rc](https://github.com/dominictarr/rc) serves its focused purpose well. cosmiconfig differs in a few key ways — making it more useful for some projects, less useful for others:
|
||||
|
||||
- Looks for configuration in some different places: in a `package.json` property, an rc file, a `.config.js` file, and rc files with extensions.
|
||||
- Built-in support for JSON, YAML, and CommonJS formats.
|
||||
- Stops at the first configuration found, instead of finding all that can be found down the filetree and merging them automatically.
|
||||
- Options.
|
||||
- Asynchronicity.
|
||||
|
||||
## Contributing & Development
|
||||
|
||||
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
||||
|
||||
And please do participate!
|
27
node_modules/cosmiconfig/index.js
generated
vendored
Normal file
27
node_modules/cosmiconfig/index.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var oshomedir = require('os-homedir');
|
||||
var minimist = require('minimist');
|
||||
var assign = require('object-assign');
|
||||
var createExplorer = require('./lib/createExplorer');
|
||||
|
||||
var parsedCliArgs = minimist(process.argv);
|
||||
|
||||
module.exports = function (moduleName, options) {
|
||||
options = assign({
|
||||
packageProp: moduleName,
|
||||
rc: '.' + moduleName + 'rc',
|
||||
js: moduleName + '.config.js',
|
||||
argv: 'config',
|
||||
rcStrictJson: false,
|
||||
stopDir: oshomedir(),
|
||||
cache: true,
|
||||
}, options);
|
||||
|
||||
if (options.argv && parsedCliArgs[options.argv]) {
|
||||
options.configPath = path.resolve(parsedCliArgs[options.argv]);
|
||||
}
|
||||
|
||||
return createExplorer(options);
|
||||
};
|
109
node_modules/cosmiconfig/lib/createExplorer.js
generated
vendored
Normal file
109
node_modules/cosmiconfig/lib/createExplorer.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var loadPackageProp = require('./loadPackageProp');
|
||||
var loadRc = require('./loadRc');
|
||||
var loadJs = require('./loadJs');
|
||||
var loadDefinedFile = require('./loadDefinedFile');
|
||||
|
||||
module.exports = function (options) {
|
||||
// These cache Promises that resolve with results, not the results themselves
|
||||
var fileCache = (options.cache) ? new Map() : null;
|
||||
var directoryCache = (options.cache) ? new Map() : null;
|
||||
var transform = options.transform || identityPromise;
|
||||
|
||||
function clearFileCache() {
|
||||
if (fileCache) fileCache.clear();
|
||||
}
|
||||
|
||||
function clearDirectoryCache() {
|
||||
if (directoryCache) directoryCache.clear();
|
||||
}
|
||||
|
||||
function clearCaches() {
|
||||
clearFileCache();
|
||||
clearDirectoryCache();
|
||||
}
|
||||
|
||||
function load(searchPath, configPath) {
|
||||
if (configPath) {
|
||||
var absoluteConfigPath = path.resolve(process.cwd(), configPath);
|
||||
if (fileCache && fileCache.has(absoluteConfigPath)) {
|
||||
return fileCache.get(absoluteConfigPath);
|
||||
}
|
||||
var result = loadDefinedFile(absoluteConfigPath, options)
|
||||
.then(transform);
|
||||
if (fileCache) fileCache.set(absoluteConfigPath, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!searchPath) return Promise.resolve(null);
|
||||
|
||||
var absoluteSearchPath = path.resolve(process.cwd(), searchPath);
|
||||
|
||||
return isDirectory(absoluteSearchPath)
|
||||
.then(function (searchPathIsDirectory) {
|
||||
var directory = (searchPathIsDirectory)
|
||||
? absoluteSearchPath
|
||||
: path.dirname(absoluteSearchPath);
|
||||
return searchDirectory(directory);
|
||||
});
|
||||
}
|
||||
|
||||
function searchDirectory(directory) {
|
||||
if (directoryCache && directoryCache.has(directory)) {
|
||||
return directoryCache.get(directory);
|
||||
}
|
||||
|
||||
var result = Promise.resolve()
|
||||
.then(function () {
|
||||
if (!options.packageProp) return;
|
||||
return loadPackageProp(directory, options);
|
||||
})
|
||||
.then(function (result) {
|
||||
if (result || !options.rc) return result;
|
||||
return loadRc(path.join(directory, options.rc), options);
|
||||
})
|
||||
.then(function (result) {
|
||||
if (result || !options.js) return result;
|
||||
return loadJs(path.join(directory, options.js));
|
||||
})
|
||||
.then(function (result) {
|
||||
if (result) return result;
|
||||
|
||||
var splitPath = directory.split(path.sep);
|
||||
var nextDirectory = (splitPath.length > 1)
|
||||
? splitPath.slice(0, -1).join(path.sep)
|
||||
: null;
|
||||
|
||||
if (!nextDirectory || directory === options.stopDir) return null;
|
||||
|
||||
return searchDirectory(nextDirectory);
|
||||
})
|
||||
.then(transform);
|
||||
|
||||
if (directoryCache) directoryCache.set(directory, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
return {
|
||||
load: load,
|
||||
clearFileCache: clearFileCache,
|
||||
clearDirectoryCache: clearDirectoryCache,
|
||||
clearCaches: clearCaches,
|
||||
};
|
||||
};
|
||||
|
||||
function isDirectory(filepath) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
fs.stat(filepath, function (err, stats) {
|
||||
if (err) return reject(err);
|
||||
return resolve(stats.isDirectory());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function identityPromise(x) {
|
||||
return Promise.resolve(x);
|
||||
}
|
66
node_modules/cosmiconfig/lib/loadDefinedFile.js
generated
vendored
Normal file
66
node_modules/cosmiconfig/lib/loadDefinedFile.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
var yaml = require('js-yaml');
|
||||
var parseJson = require('parse-json');
|
||||
var requireFromString = require('require-from-string');
|
||||
var readFile = require('./readFile');
|
||||
|
||||
module.exports = function (filepath, options) {
|
||||
return readFile(filepath, { throwNotFound: true }).then(function (content) {
|
||||
var parsedConfig = (function () {
|
||||
switch (options.format) {
|
||||
case 'json':
|
||||
return parseJson(content, filepath);
|
||||
case 'yaml':
|
||||
return yaml.safeLoad(content, {
|
||||
filename: filepath,
|
||||
});
|
||||
case 'js':
|
||||
return requireFromString(content, filepath);
|
||||
default:
|
||||
return tryAllParsing(content, filepath);
|
||||
}
|
||||
})();
|
||||
|
||||
if (!parsedConfig) {
|
||||
throw new Error(
|
||||
'Failed to parse "' + filepath + '" as JSON, JS, or YAML.'
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
config: parsedConfig,
|
||||
filepath: filepath,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
function tryAllParsing(content, filepath) {
|
||||
return tryYaml(content, filepath, function () {
|
||||
return tryRequire(content, filepath, function () {
|
||||
return null;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function tryYaml(content, filepath, cb) {
|
||||
try {
|
||||
var result = yaml.safeLoad(content, {
|
||||
filename: filepath,
|
||||
});
|
||||
if (typeof result === 'string') {
|
||||
return cb();
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
return cb();
|
||||
}
|
||||
}
|
||||
|
||||
function tryRequire(content, filepath, cb) {
|
||||
try {
|
||||
return requireFromString(content, filepath);
|
||||
} catch (e) {
|
||||
return cb();
|
||||
}
|
||||
}
|
15
node_modules/cosmiconfig/lib/loadJs.js
generated
vendored
Normal file
15
node_modules/cosmiconfig/lib/loadJs.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var requireFromString = require('require-from-string');
|
||||
var readFile = require('./readFile');
|
||||
|
||||
module.exports = function (filepath) {
|
||||
return readFile(filepath).then(function (content) {
|
||||
if (!content) return null;
|
||||
|
||||
return {
|
||||
config: requireFromString(content, filepath),
|
||||
filepath: filepath,
|
||||
};
|
||||
});
|
||||
};
|
21
node_modules/cosmiconfig/lib/loadPackageProp.js
generated
vendored
Normal file
21
node_modules/cosmiconfig/lib/loadPackageProp.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var parseJson = require('parse-json');
|
||||
var readFile = require('./readFile');
|
||||
|
||||
module.exports = function (packageDir, options) {
|
||||
var packagePath = path.join(packageDir, 'package.json');
|
||||
|
||||
return readFile(packagePath).then(function (content) {
|
||||
if (!content) return null;
|
||||
var parsedContent = parseJson(content, packagePath);
|
||||
var packagePropValue = parsedContent[options.packageProp];
|
||||
if (!packagePropValue) return null;
|
||||
|
||||
return {
|
||||
config: packagePropValue,
|
||||
filepath: packagePath,
|
||||
};
|
||||
});
|
||||
};
|
85
node_modules/cosmiconfig/lib/loadRc.js
generated
vendored
Normal file
85
node_modules/cosmiconfig/lib/loadRc.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
var yaml = require('js-yaml');
|
||||
var parseJson = require('parse-json');
|
||||
var requireFromString = require('require-from-string');
|
||||
var readFile = require('./readFile');
|
||||
|
||||
module.exports = function (filepath, options) {
|
||||
return loadExtensionlessRc().then(function (result) {
|
||||
if (result) return result;
|
||||
if (options.rcExtensions) return loadRcWithExtensions();
|
||||
return null;
|
||||
});
|
||||
|
||||
function loadExtensionlessRc() {
|
||||
return readRcFile().then(function (content) {
|
||||
if (!content) return null;
|
||||
|
||||
var pasedConfig = (options.rcStrictJson)
|
||||
? parseJson(content, filepath)
|
||||
: yaml.safeLoad(content, {
|
||||
filename: filepath,
|
||||
});
|
||||
return {
|
||||
config: pasedConfig,
|
||||
filepath: filepath,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function loadRcWithExtensions() {
|
||||
return readRcFile('json').then(function (content) {
|
||||
if (content) {
|
||||
var successFilepath = filepath + '.json';
|
||||
return {
|
||||
config: parseJson(content, successFilepath),
|
||||
filepath: successFilepath,
|
||||
};
|
||||
}
|
||||
// If not content was found in the file with extension,
|
||||
// try the next possible extension
|
||||
return readRcFile('yaml');
|
||||
}).then(function (content) {
|
||||
if (content) {
|
||||
// If the previous check returned an object with a config
|
||||
// property, then it succeeded and this step can be skipped
|
||||
if (content.config) return content;
|
||||
// If it just returned a string, then *this* check succeeded
|
||||
var successFilepath = filepath + '.yaml';
|
||||
return {
|
||||
config: yaml.safeLoad(content, { filename: successFilepath }),
|
||||
filepath: successFilepath,
|
||||
};
|
||||
}
|
||||
return readRcFile('yml');
|
||||
}).then(function (content) {
|
||||
if (content) {
|
||||
if (content.config) return content;
|
||||
var successFilepath = filepath + '.yml';
|
||||
return {
|
||||
config: yaml.safeLoad(content, { filename: successFilepath }),
|
||||
filepath: successFilepath,
|
||||
};
|
||||
}
|
||||
return readRcFile('js');
|
||||
}).then(function (content) {
|
||||
if (content) {
|
||||
if (content.config) return content;
|
||||
var successFilepath = filepath + '.js';
|
||||
return {
|
||||
config: requireFromString(content, successFilepath),
|
||||
filepath: successFilepath,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
function readRcFile(extension) {
|
||||
var filepathWithExtension = (extension)
|
||||
? filepath + '.' + extension
|
||||
: filepath;
|
||||
return readFile(filepathWithExtension);
|
||||
}
|
||||
};
|
20
node_modules/cosmiconfig/lib/readFile.js
generated
vendored
Normal file
20
node_modules/cosmiconfig/lib/readFile.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
module.exports = function (filepath, options) {
|
||||
options = options || {};
|
||||
options.throwNotFound = options.throwNotFound || false;
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
fs.readFile(filepath, 'utf8', function (err, content) {
|
||||
if (err && err.code === 'ENOENT' && !options.throwNotFound) {
|
||||
return resolve(null);
|
||||
}
|
||||
|
||||
if (err) return reject(err);
|
||||
|
||||
resolve(content);
|
||||
});
|
||||
});
|
||||
};
|
114
node_modules/cosmiconfig/package.json
generated
vendored
Normal file
114
node_modules/cosmiconfig/package.json
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"cosmiconfig@^2.1.1",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint"
|
||||
]
|
||||
],
|
||||
"_from": "cosmiconfig@>=2.1.1 <3.0.0",
|
||||
"_id": "cosmiconfig@2.1.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/cosmiconfig",
|
||||
"_nodeVersion": "4.6.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-18-east.internal.npmjs.com",
|
||||
"tmp": "tmp/cosmiconfig-2.1.1.tgz_1480883998374_0.7163176657631993"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "david.dave.clark@gmail.com",
|
||||
"name": "davidtheclark"
|
||||
},
|
||||
"_npmVersion": "4.0.2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "cosmiconfig",
|
||||
"raw": "cosmiconfig@^2.1.1",
|
||||
"rawSpec": "^2.1.1",
|
||||
"scope": null,
|
||||
"spec": ">=2.1.1 <3.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/stylelint"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-2.1.1.tgz",
|
||||
"_shasum": "817f2c2039347a1e9bf7d090c0923e53f749ca82",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "cosmiconfig@^2.1.1",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint",
|
||||
"author": {
|
||||
"email": "david.dave.clark@gmail.com",
|
||||
"name": "David Clark"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/davidtheclark/cosmiconfig/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Bogdan Chadkin",
|
||||
"email": "trysound@yandex.ru"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"js-yaml": "^3.4.3",
|
||||
"minimist": "^1.2.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"os-homedir": "^1.0.1",
|
||||
"parse-json": "^2.2.0",
|
||||
"require-from-string": "^1.1.0"
|
||||
},
|
||||
"description": "Find and load configuration from a package.json property, rc file, or CommonJS module",
|
||||
"devDependencies": {
|
||||
"ava": "0.16.0",
|
||||
"eslint": "3.5.0",
|
||||
"eslint-config-davidtheclark-node": "^0.2.0",
|
||||
"eslint-plugin-node": "^2.0.0",
|
||||
"expect": "^1.20.2",
|
||||
"lodash": "4.16.1",
|
||||
"node-version-check": "^2.1.1",
|
||||
"nyc": "^8.3.0",
|
||||
"sinon": "1.17.6"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "817f2c2039347a1e9bf7d090c0923e53f749ca82",
|
||||
"tarball": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-2.1.1.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib"
|
||||
],
|
||||
"gitHead": "833385b0897c7d698e346442cc260a40f0e8eb9d",
|
||||
"homepage": "https://github.com/davidtheclark/cosmiconfig#readme",
|
||||
"keywords": [
|
||||
"config",
|
||||
"configuration",
|
||||
"load"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "davidtheclark",
|
||||
"email": "david.dave.clark@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "cosmiconfig",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/davidtheclark/cosmiconfig.git"
|
||||
},
|
||||
"scripts": {
|
||||
"ava": "ava test/*.test.js",
|
||||
"coverage": "nyc npm run ava && nyc report --reporter=html && open coverage/index.html",
|
||||
"lint": "node-version-gte-4 && eslint . || echo \"ESLint not supported\"",
|
||||
"test": "npm run ava && npm run lint"
|
||||
},
|
||||
"version": "2.1.1"
|
||||
}
|
Reference in New Issue
Block a user