Fix the undefined opts bug
This commit is contained in:
parent
7e19c944b9
commit
c20285dd36
@ -5,6 +5,10 @@
|
|||||||
{
|
{
|
||||||
"note": "Fix a bug when smart recompilation wasn't working because of remappings",
|
"note": "Fix a bug when smart recompilation wasn't working because of remappings",
|
||||||
"pr": 1575
|
"pr": 1575
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Fix a bug when opts could not be undefined",
|
||||||
|
"pr": "TODO"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -96,12 +96,12 @@ export class Compiler {
|
|||||||
* @return An instance of the Compiler class.
|
* @return An instance of the Compiler class.
|
||||||
*/
|
*/
|
||||||
constructor(opts?: CompilerOptions) {
|
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
|
// TODO: Look for config file in parent directories if not found in current directory
|
||||||
const config: CompilerOptions = fs.existsSync(CONFIG_FILE)
|
const config: CompilerOptions = fs.existsSync(CONFIG_FILE)
|
||||||
? JSON.parse(fs.readFileSync(CONFIG_FILE).toString())
|
? JSON.parse(fs.readFileSync(CONFIG_FILE).toString())
|
||||||
: {};
|
: {};
|
||||||
const passedOpts = opts || {};
|
|
||||||
assert.doesConformToSchema('compiler.json', config, compilerOptionsSchema);
|
assert.doesConformToSchema('compiler.json', config, compilerOptionsSchema);
|
||||||
this._contractsDir = path.resolve(passedOpts.contractsDir || config.contractsDir || DEFAULT_CONTRACTS_DIR);
|
this._contractsDir = path.resolve(passedOpts.contractsDir || config.contractsDir || DEFAULT_CONTRACTS_DIR);
|
||||||
this._solcVersionIfExists = passedOpts.solcVersion || config.solcVersion;
|
this._solcVersionIfExists = passedOpts.solcVersion || config.solcVersion;
|
||||||
|
@ -23,6 +23,9 @@ describe('#Compiler', function(): void {
|
|||||||
contractsDir,
|
contractsDir,
|
||||||
contracts: constants.contracts,
|
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 () => {
|
it('should create an Exchange artifact with the correct unlinked binary', async () => {
|
||||||
compilerOpts.contracts = ['Exchange'];
|
compilerOpts.contracts = ['Exchange'];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user