aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sol-cov/src')
-rw-r--r--packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts15
1 files changed, 12 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 cb164f769..d08828bf6 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
@@ -7,13 +7,22 @@ import { ContractData } from '../types';
import { AbstractArtifactAdapter } from './abstract_artifact_adapter';
+const CONFIG_FILE = 'compiler.json';
+
export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter {
private _artifactsPath: string;
private _sourcesPath: string;
- constructor(artifactsPath: string, sourcesPath: string) {
+ constructor(artifactsPath?: string, sourcesPath?: string) {
super();
- this._artifactsPath = artifactsPath;
- this._sourcesPath = sourcesPath;
+ const config = JSON.parse(fs.readFileSync(CONFIG_FILE).toString());
+ if (_.isUndefined(artifactsPath) && _.isUndefined(config.artifactsDir)) {
+ throw new Error(`artifactsDir not found in ${CONFIG_FILE}`);
+ }
+ this._artifactsPath = config.artifactsDir;
+ if (_.isUndefined(sourcesPath) && _.isUndefined(config.contractsDir)) {
+ throw new Error(`contractsDir not found in ${CONFIG_FILE}`);
+ }
+ this._sourcesPath = config.contractsDir;
}
public async collectContractsDataAsync(): Promise<ContractData[]> {
const artifactsGlob = `${this._artifactsPath}/**/*.json`;