Fix the undefined opts bug

This commit is contained in:
Leonid Logvinov
2019-02-07 12:30:54 +01:00
parent 7e19c944b9
commit c20285dd36
3 changed files with 9 additions and 2 deletions

View File

@@ -96,12 +96,12 @@ export class Compiler {
* @return An instance of the Compiler class.
*/
constructor(opts?: CompilerOptions) {
assert.doesConformToSchema('opts', opts, compilerOptionsSchema);
const passedOpts = opts || {};
assert.doesConformToSchema('opts', passedOpts, compilerOptionsSchema);
// TODO: Look for config file in parent directories if not found in current directory
const config: CompilerOptions = fs.existsSync(CONFIG_FILE)
? JSON.parse(fs.readFileSync(CONFIG_FILE).toString())
: {};
const passedOpts = opts || {};
assert.doesConformToSchema('compiler.json', config, compilerOptionsSchema);
this._contractsDir = path.resolve(passedOpts.contractsDir || config.contractsDir || DEFAULT_CONTRACTS_DIR);
this._solcVersionIfExists = passedOpts.solcVersion || config.solcVersion;