diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-02-07 19:30:54 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-02-07 19:30:54 +0800 |
commit | c20285dd3655a9685b52205229e675c797cd4418 (patch) | |
tree | 2577945be926336f7a39a05d7c35e57a8a0251f7 | |
parent | 7e19c944b91f573bb026ca3a916cd4e4b9169a9e (diff) | |
download | dexon-0x-contracts-c20285dd3655a9685b52205229e675c797cd4418.tar.gz dexon-0x-contracts-c20285dd3655a9685b52205229e675c797cd4418.tar.zst dexon-0x-contracts-c20285dd3655a9685b52205229e675c797cd4418.zip |
Fix the undefined opts bug
-rw-r--r-- | packages/sol-compiler/CHANGELOG.json | 4 | ||||
-rw-r--r-- | packages/sol-compiler/src/compiler.ts | 4 | ||||
-rw-r--r-- | packages/sol-compiler/test/compiler_test.ts | 3 |
3 files changed, 9 insertions, 2 deletions
diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index dd65f3aed..a0d2250aa 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -5,6 +5,10 @@ { "note": "Fix a bug when smart recompilation wasn't working because of remappings", "pr": 1575 + }, + { + "note": "Fix a bug when opts could not be undefined", + "pr": "TODO" } ] }, diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index c5dea1155..686ba4f82 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -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; diff --git a/packages/sol-compiler/test/compiler_test.ts b/packages/sol-compiler/test/compiler_test.ts index 464aa8bb6..5cc7e41ce 100644 --- a/packages/sol-compiler/test/compiler_test.ts +++ b/packages/sol-compiler/test/compiler_test.ts @@ -23,6 +23,9 @@ describe('#Compiler', function(): void { contractsDir, contracts: constants.contracts, }; + it('should create a Compiler with empty opts', async () => { + const _compiler = new Compiler(); + }); it('should create an Exchange artifact with the correct unlinked binary', async () => { compilerOpts.contracts = ['Exchange']; |