Socket
Socket
Sign inDemoInstall

cosmiconfig

Package Overview
Dependencies
9
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.1 to 5.0.2

4

CHANGELOG.md
# 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 @@

12

dist/createExplorer.js

@@ -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:

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