Comparing version 2.1.0 to 2.1.1
class ConfigMissingError extends Error { | ||
constructor(configName) { | ||
const message = `Failed to load config "${configName}" to extend from.` | ||
let message = `Failed to load a solhint's config file.` | ||
if (configName) message = `Failed to load config "${configName}" to extend from.` | ||
super(message) | ||
@@ -5,0 +6,0 @@ } |
@@ -33,3 +33,7 @@ const path = require('path') | ||
const loadConfig = () => { | ||
const loadConfig = configFile => { | ||
if (configFile && !fs.existsSync(configFile)) { | ||
throw new Error(`The config file passed as a parameter does not exist`) | ||
} | ||
// Use cosmiconfig to get the config from different sources | ||
@@ -51,4 +55,11 @@ const appDirectory = fs.realpathSync(process.cwd()) | ||
if (configFile) { | ||
cosmiconfigOptions.searchPlaces.push(configFile) | ||
} | ||
const explorer = cosmiconfig(moduleName, cosmiconfigOptions) | ||
const searchedFor = explorer.searchSync(appDirectory) | ||
if (!searchedFor) { | ||
throw new ConfigMissingError() | ||
} | ||
return searchedFor.config || createEmptyConfig() | ||
@@ -55,0 +66,0 @@ } |
{ | ||
"name": "solhint", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Solidity Code Linter", | ||
@@ -5,0 +5,0 @@ "main": "solhint.js", |
@@ -128,6 +128,6 @@ #!/usr/bin/env node | ||
try { | ||
config = loadConfig() | ||
config = loadConfig(program.config) | ||
} catch (e) { | ||
console.log(e.message) | ||
process.exit(0) | ||
process.exit(1) | ||
} | ||
@@ -134,0 +134,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
747453
180
16913