aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-compiler
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sol-compiler')
-rw-r--r--packages/sol-compiler/src/compiler.ts25
1 files changed, 12 insertions, 13 deletions
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts
index f0cb2ded3..390c2412a 100644
--- a/packages/sol-compiler/src/compiler.ts
+++ b/packages/sol-compiler/src/compiler.ts
@@ -172,19 +172,7 @@ export class Compiler {
path.join(this._contractsDir, contractSource.path),
).toString('hex')}`,
};
- let shouldCompile = false;
- if (_.isUndefined(contractPathToData[contractSource.path].currentArtifactIfExists)) {
- shouldCompile = true;
- } else {
- const currentArtifact = contractPathToData[contractSource.path]
- .currentArtifactIfExists as ContractArtifact;
- const isUserOnLatestVersion = currentArtifact.schemaVersion === constants.LATEST_ARTIFACT_VERSION;
- const didCompilerSettingsChange = !_.isEqual(currentArtifact.compiler.settings, this._compilerSettings);
- const didSourceChange =
- currentArtifact.sourceTreeHashHex !== contractPathToData[contractSource.path].sourceTreeHashHex;
- shouldCompile = !isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange;
- }
- if (!shouldCompile) {
+ if (!this._shouldCompile(contractPathToData[contractSource.path])) {
continue;
}
const solcVersion = _.isUndefined(this._solcVersionIfExists)
@@ -231,6 +219,17 @@ export class Compiler {
}
}
}
+ private _shouldCompile(contractData: ContractData): boolean {
+ if (_.isUndefined(contractData.currentArtifactIfExists)) {
+ return true;
+ } else {
+ const currentArtifact = contractData.currentArtifactIfExists as ContractArtifact;
+ const isUserOnLatestVersion = currentArtifact.schemaVersion === constants.LATEST_ARTIFACT_VERSION;
+ const didCompilerSettingsChange = !_.isEqual(currentArtifact.compiler.settings, this._compilerSettings);
+ const didSourceChange = currentArtifact.sourceTreeHashHex !== contractData.sourceTreeHashHex;
+ return !isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange;
+ }
+ }
private async _verifyAndPersistCompiledContractAsync(
contractPath: string,
contractMetadata: ContractData,