diff options
Diffstat (limited to 'packages/sol-cov/src/artifact_adapters')
-rw-r--r-- | packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts b/packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts index 6e385203b..051782ba4 100644 --- a/packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts +++ b/packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts @@ -1,3 +1,5 @@ +import { ContractArtifact } from '@0xproject/sol-compiler'; +import { logUtils } from '@0xproject/utils'; import * as fs from 'fs'; import * as glob from 'glob'; import * as _ from 'lodash'; @@ -18,18 +20,22 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter { if (_.isUndefined(artifactsPath) && _.isUndefined(config.artifactsDir)) { throw new Error(`artifactsDir not found in ${CONFIG_FILE}`); } - this._artifactsPath = config.artifactsDir; + this._artifactsPath = artifactsPath || config.artifactsDir; if (_.isUndefined(sourcesPath) && _.isUndefined(config.contractsDir)) { throw new Error(`contractsDir not found in ${CONFIG_FILE}`); } - this._sourcesPath = config.contractsDir; + this._sourcesPath = sourcesPath || config.contractsDir; } public async collectContractsDataAsync(): Promise<ContractData[]> { const artifactsGlob = `${this._artifactsPath}/**/*.json`; const artifactFileNames = glob.sync(artifactsGlob, { absolute: true }); const contractsData: ContractData[] = []; for (const artifactFileName of artifactFileNames) { - const artifact = JSON.parse(fs.readFileSync(artifactFileName).toString()); + const artifact: ContractArtifact = JSON.parse(fs.readFileSync(artifactFileName).toString()); + if (_.isUndefined(artifact.compilerOutput.evm)) { + logUtils.warn(`${artifactFileName} doesn't contain bytecode. Skipping...`); + continue; + } let sources = _.keys(artifact.sources); sources = _.map(sources, relativeFilePath => path.resolve(this._sourcesPath, relativeFilePath)); const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString()); |