Socket
Socket
Sign inDemoInstall

cosmiconfig

Package Overview
Dependencies
24
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.0 to 7.0.0

5

CHANGELOG.md
# Changelog
## 7.0.0
- **Breaking change:** Add `${moduleName}rc.cjs` and `${moduleName}.config.cjs` to the default `searchPlaces`, to support users of `"type": "module"` in recent versions of Node.
- **Breaking change:** Drop support for Node 8. Now requires Node 10+.
## 6.0.0

@@ -4,0 +9,0 @@

35

dist/Explorer.js

@@ -20,4 +20,2 @@ "use strict";

function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); }
class Explorer extends _ExplorerBase.ExplorerBase {

@@ -57,32 +55,11 @@ constructor(options) {

async searchDirectory(dir) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
for await (const place of this.config.searchPlaces) {
const placeResult = await this.loadSearchPlace(dir, place);
var _iteratorError;
if (this.shouldSearchStopWithResult(placeResult) === true) {
return placeResult;
}
} // config not found
try {
for (var _iterator = _asyncIterator(this.config.searchPlaces), _step, _value; _step = await _iterator.next(), _iteratorNormalCompletion = _step.done, _value = await _step.value, !_iteratorNormalCompletion; _iteratorNormalCompletion = true) {
const place = _value;
const placeResult = await this.loadSearchPlace(dir, place);
if (this.shouldSearchStopWithResult(placeResult) === true) {
return placeResult;
}
} // config not found
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
await _iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return null;

@@ -89,0 +66,0 @@ }

@@ -8,3 +8,3 @@ import { Config, CosmiconfigResult, Loaders, LoadersSync } from './types';

interface OptionsBase {
packageProp?: string;
packageProp?: string | Array<string>;
searchPlaces?: Array<string>;

@@ -38,2 +38,3 @@ ignoreEmptySearchPlaces?: boolean;

declare const defaultLoaders: Readonly<{
readonly '.cjs': LoaderSync;
readonly '.js': LoaderSync;

@@ -40,0 +41,0 @@ readonly '.json': LoaderSync;

@@ -22,2 +22,3 @@ "use strict";

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

@@ -51,2 +52,3 @@ function cosmiconfig(moduleName, options = {}) {

const defaultLoaders = Object.freeze({
'.cjs': _loaders.loaders.loadJs,
'.js': _loaders.loaders.loadJs,

@@ -60,6 +62,10 @@ '.json': _loaders.loaders.loadJson,

const identity = function identity(x) {
return x;
};
function normalizeOptions(moduleName, options) {
const defaults = {
packageProp: moduleName,
searchPlaces: ['package.json', `.${moduleName}rc`, `.${moduleName}rc.json`, `.${moduleName}rc.yaml`, `.${moduleName}rc.yml`, `.${moduleName}rc.js`, `${moduleName}.config.js`],
searchPlaces: ['package.json', `.${moduleName}rc`, `.${moduleName}rc.json`, `.${moduleName}rc.yaml`, `.${moduleName}rc.yml`, `.${moduleName}rc.js`, `.${moduleName}rc.cjs`, `${moduleName}.config.js`, `${moduleName}.config.cjs`],
ignoreEmptySearchPlaces: true,

@@ -79,6 +85,2 @@ stopDir: _os.default.homedir(),

}
const identity = function identity(x) {
return x;
};
//# sourceMappingURL=index.js.map
{
"name": "cosmiconfig",
"version": "6.0.0",
"version": "7.0.0",
"description": "Find and load configuration from a package.json property, rc file, or CommonJS module",

@@ -37,13 +37,10 @@ "main": "dist/index.js",

"eslint --fix",
"prettier --write",
"git add"
"prettier --write"
],
"*.{json,yml,yaml}": [
"prettier --write",
"git add"
"prettier --write"
],
"*.md": [
"remark-preset-davidtheclark",
"remark-preset-davidtheclark --format",
"git add"
"remark-preset-davidtheclark --format"
]

@@ -105,3 +102,3 @@ },

"targets": {
"node": "8.9"
"node": "10"
}

@@ -115,37 +112,37 @@ }

"@types/parse-json": "^4.0.0",
"import-fresh": "^3.1.0",
"import-fresh": "^3.2.1",
"parse-json": "^5.0.0",
"path-type": "^4.0.0",
"yaml": "^1.7.2"
"yaml": "^1.10.0"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3",
"@babel/preset-typescript": "^7.6.0",
"@types/jest": "^24.0.19",
"@types/node": "^12.11.5",
"@typescript-eslint/eslint-plugin": "^2.5.0",
"@typescript-eslint/parser": "^2.5.0",
"cross-env": "^6.0.3",
"@babel/cli": "^7.10.4",
"@babel/core": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/preset-typescript": "^7.10.4",
"@types/jest": "^26.0.4",
"@types/node": "^14.0.22",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"cross-env": "^7.0.2",
"del": "^5.1.0",
"del-cli": "^3.0.0",
"eslint": "^6.5.1",
"del-cli": "^3.0.1",
"eslint": "^7.4.0",
"eslint-config-davidtheclark-node": "^0.2.2",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.20.0",
"eslint-plugin-node": "^10.0.0",
"husky": "^3.0.9",
"jest": "^24.9.0",
"lint-staged": "^9.4.2",
"make-dir": "^3.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.18.0",
"eslint-plugin-node": "^11.1.0",
"husky": "^4.2.5",
"jest": "^26.1.0",
"lint-staged": "^10.2.11",
"make-dir": "^3.1.0",
"parent-module": "^2.0.0",
"prettier": "^1.18.2",
"remark-preset-davidtheclark": "^0.10.0",
"typescript": "^3.6.4"
"prettier": "^2.0.5",
"remark-preset-davidtheclark": "^0.12.0",
"typescript": "^3.9.6"
},
"engines": {
"node": ">=8"
"node": ">=10"
}
}

@@ -15,4 +15,4 @@ # cosmiconfig

- a JSON or YAML, extensionless "rc file"
- an "rc file" with the extensions `.json`, `.yaml`, `.yml`, or `.js`.
- a `.config.js` CommonJS module
- an "rc file" with the extensions `.json`, `.yaml`, `.yml`, `.js`, or `.cjs`
- a `.config.js` or `.config.cjs` CommonJS module

@@ -23,13 +23,7 @@ For example, if your module's name is "myapp", cosmiconfig will search up the directory tree for configuration in the following places:

- a `.myapprc` file in JSON or YAML format
- a `.myapprc.json` file
- a `.myapprc.yaml`, `.myapprc.yml`, or `.myapprc.js` file
- a `myapp.config.js` file exporting a JS object
- a `.myapprc.json`, `.myapprc.yaml`, `.myapprc.yml`, `.myapprc.js`, or `.myapprc.cjs` file
- a `myapp.config.js` or `myapp.config.cjs` CommonJS module exporting an object
Cosmiconfig continues to search up the directory tree, checking each of these places in each directory, until it finds some acceptable configuration (or hits the home directory).
👀 **Looking for the v5 docs?**
v6 involves slight changes to Cosmiconfig's API, clarifying the difference between synchronous and asynchronous usage.
If you have trouble switching from v5 to v6, please file an issue.
If you are still using v5, those v5 docs are available [in the `5.x.x` tagged code](https://github.com/davidtheclark/cosmiconfig/tree/5.2.1).
## Table of contents

@@ -41,3 +35,3 @@

- [Asynchronous API](#asynchronous-api)
- [cosmiconfig()](#cosmiconfig)
- [cosmiconfig()](#cosmiconfig-1)
- [explorer.search()](#explorersearch)

@@ -48,3 +42,3 @@ - [explorer.load()](#explorerload)

- [explorer.clearCaches()](#explorerclearcaches)
- [Synchronsous API](#synchronsous-api)
- [Synchronous API](#synchronous-api)
- [cosmiconfigSync()](#cosmiconfigsync)

@@ -74,3 +68,3 @@ - [explorerSync.search()](#explorersyncsearch)

Tested in Node 8+.
Tested in Node 10+.

@@ -156,5 +150,4 @@ ## Usage

2. A `.goldengrahamsrc` file with JSON or YAML syntax.
3. A `.goldengrahamsrc.json` file.
4. A `.goldengrahamsrc.yaml`, `.goldengrahamsrc.yml`, or `.goldengrahamsrc.js` file.
5. A `goldengrahams.config.js` JS file exporting the object.
3. A `.goldengrahamsrc.json`, `.goldengrahamsrc.yaml`, `.goldengrahamsrc.yml`, `.goldengrahamsrc.js`, or `.goldengrahamsrc.cjs` file.
4. A `goldengrahams.config.js` or `goldengrahams.config.cjs` CommonJS module exporting the object.
- If none of those searches reveal a configuration object, move up one directory level and try again.

@@ -213,3 +206,3 @@ So the search continues in `./`, `../`, `../../`, `../../../`, etc., checking the same places in each directory.

## Synchronsous API
## Synchronous API

@@ -283,3 +276,5 @@ ### cosmiconfigSync()

`.${moduleName}rc.js`,
`.${moduleName}rc.cjs`,
`${moduleName}.config.js`,
`${moduleName}.config.cjs`,
]

@@ -359,2 +354,3 @@ ```

// [
// [ '.cjs', [Function: loadJs] ],
// [ '.js', [Function: loadJs] ],

@@ -361,0 +357,0 @@ // [ '.json', [Function: loadJson] ],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc