aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-06-12 07:10:56 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-06-12 07:10:56 +0800
commitf4a61b4c70b18cd4eef70eafc79e14b8c0161df3 (patch)
tree26d26f96889982dd5b4e0a270201c053c3252802 /packages
parent6eebd693ce902068c58eac81c8d29cbfd48c1b86 (diff)
downloaddexon-sol-tools-f4a61b4c70b18cd4eef70eafc79e14b8c0161df3.tar
dexon-sol-tools-f4a61b4c70b18cd4eef70eafc79e14b8c0161df3.tar.gz
dexon-sol-tools-f4a61b4c70b18cd4eef70eafc79e14b8c0161df3.tar.bz2
dexon-sol-tools-f4a61b4c70b18cd4eef70eafc79e14b8c0161df3.tar.lz
dexon-sol-tools-f4a61b4c70b18cd4eef70eafc79e14b8c0161df3.tar.xz
dexon-sol-tools-f4a61b4c70b18cd4eef70eafc79e14b8c0161df3.tar.zst
dexon-sol-tools-f4a61b4c70b18cd4eef70eafc79e14b8c0161df3.zip
Don't throw when no config file is found
Diffstat (limited to 'packages')
-rw-r--r--packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts10
1 files changed, 6 insertions, 4 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 051782ba4..220a9f98c 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,4 +1,4 @@
-import { ContractArtifact } from '@0xproject/sol-compiler';
+import { CompilerOptions, ContractArtifact } from '@0xproject/sol-compiler';
import { logUtils } from '@0xproject/utils';
import * as fs from 'fs';
import * as glob from 'glob';
@@ -16,15 +16,17 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter {
private _sourcesPath: string;
constructor(artifactsPath?: string, sourcesPath?: string) {
super();
- const config = JSON.parse(fs.readFileSync(CONFIG_FILE).toString());
+ const config: CompilerOptions = fs.existsSync(CONFIG_FILE)
+ ? JSON.parse(fs.readFileSync(CONFIG_FILE).toString())
+ : {};
if (_.isUndefined(artifactsPath) && _.isUndefined(config.artifactsDir)) {
throw new Error(`artifactsDir not found in ${CONFIG_FILE}`);
}
- this._artifactsPath = artifactsPath || config.artifactsDir;
+ this._artifactsPath = (artifactsPath || config.artifactsDir) as string;
if (_.isUndefined(sourcesPath) && _.isUndefined(config.contractsDir)) {
throw new Error(`contractsDir not found in ${CONFIG_FILE}`);
}
- this._sourcesPath = sourcesPath || config.contractsDir;
+ this._sourcesPath = (sourcesPath || config.contractsDir) as string;
}
public async collectContractsDataAsync(): Promise<ContractData[]> {
const artifactsGlob = `${this._artifactsPath}/**/*.json`;