cosmiconfig
Advanced tools
Comparing version 5.0.1 to 5.0.2
# Changelog | ||
## 5.0.2 | ||
- Fixed: Allow `searchSync` and `loadSync` to load JS configuration files whose export is a Promise. | ||
## 5.0.1 | ||
@@ -4,0 +8,0 @@ |
@@ -226,13 +226,3 @@ // | ||
: this.getAsyncLoaderForFile(filepath); | ||
const loadedContent = loader(filepath, content); | ||
if (mode === MODE_SYNC && loadedContent instanceof Promise) { | ||
throw new Error( | ||
`The sync loader for "${path.basename( | ||
filepath | ||
)}" returned a Promise. Sync loaders need to be synchronous.` | ||
); | ||
} | ||
return loadedContent; | ||
return loader(filepath, content); | ||
} | ||
@@ -239,0 +229,0 @@ |
{ | ||
"name": "cosmiconfig", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Find and load configuration from a package.json property, rc file, or CommonJS module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -17,9 +17,9 @@ # cosmiconfig | ||
For example, if your module's name is "soursocks", cosmiconfig will search for configuration in the following places: | ||
For example, if your module's name is "soursocks", cosmiconfig will search up the directory tree for configuration in the following places: | ||
- a `soursocks` property in `package.json` (anywhere up the directory tree) | ||
- a `.soursocksrc` file in JSON or YAML format (anywhere up the directory tree) | ||
- a `soursocks` property in `package.json` | ||
- a `.soursocksrc` file in JSON or YAML format | ||
- a `.soursocksrc.json` file | ||
- a `.soursocksrc.yaml` or `.soursocksrc.yml` file | ||
- a `soursocks.config.js` file exporting a JS object (anywhere up the directory tree) | ||
- a `soursocks.config.js` file exporting a JS object | ||
@@ -358,6 +358,7 @@ 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). | ||
If an extension has *only* an async loader but you try to use [`searchSync()`] or [`loadSync()`], an error will be thrown. | ||
A few things to note: | ||
Note that **special JS syntax can also be handled by using a `require` hook**, because `cosmiconfig.loadJs` just uses `require`. | ||
Whether you use custom loaders or a `require` hook is up to you. | ||
- If you use a custom loader, be aware of whether it's sync or async and how that aligned with your usage of sync or async search and load functions. | ||
- **Special JS syntax can also be handled by using a `require` hook**, because `cosmiconfig.loadJs` just uses `require`. | ||
Whether you use custom loaders or a `require` hook is up to you. | ||
@@ -364,0 +365,0 @@ Examples: |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
493
0
39929
423