Socket
Socket
Sign inDemoInstall

cosmiconfig

Package Overview
Dependencies
14
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

4

CHANGELOG.md
# Changelog
## 1.0.2
- Fix handling of `require()`'s within JS module configs.
## 1.0.1

@@ -4,0 +8,0 @@

27

lib/loadDefinedFile.js

@@ -31,4 +31,3 @@ 'use strict';

// require-from-string will return unparseable JS as a string
if (!parsedConfig || typeof parsedConfig === 'string') {
if (!parsedConfig) {
throw new Error(

@@ -46,5 +45,5 @@ 'Failed to parse "' + filepath + '" as JSON, JS, or YAML.'

function tryAllParsing(content) {
return tryParsing(content, yaml.safeLoad, function() {
return tryParsing(content, requireFromString, function() {
function tryAllParsing(content, filepath) {
return tryYaml(content, filepath, function() {
return tryRequire(content, filepath, function() {
return null;

@@ -55,5 +54,11 @@ });

function tryParsing(content, parser, cb) {
function tryYaml(content, filepath, cb) {
try {
return parser(content);
var result = yaml.safeLoad(content, {
filename: filepath,
});
if (typeof result === 'string') {
return cb();
}
return result;
} catch (e) {

@@ -63,1 +68,9 @@ return cb();

}
function tryRequire(content, filepath, cb) {
try {
return requireFromString(content, filepath);
} catch (e) {
return cb();
}
}
{
"name": "cosmiconfig",
"version": "1.0.1",
"version": "1.0.2",
"description": "Find and load configuration from a package.json property, rc file, or CommonJS module",

@@ -45,6 +45,6 @@ "main": "index.js",

"devDependencies": {
"ava": "^0.5.0",
"eslint": "1.9.0",
"ava": "0.9.1",
"eslint": "1.10.3",
"sinon": "1.17.2"
}
}
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