extract method _shouldCompile()
This commit is contained in:
parent
89202b7bdf
commit
badcb35525
@ -172,19 +172,7 @@ export class Compiler {
|
|||||||
path.join(this._contractsDir, contractSource.path),
|
path.join(this._contractsDir, contractSource.path),
|
||||||
).toString('hex')}`,
|
).toString('hex')}`,
|
||||||
};
|
};
|
||||||
let shouldCompile = false;
|
if (!this._shouldCompile(contractPathToData[contractSource.path])) {
|
||||||
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) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const solcVersion = _.isUndefined(this._solcVersionIfExists)
|
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(
|
private async _verifyAndPersistCompiledContractAsync(
|
||||||
contractPath: string,
|
contractPath: string,
|
||||||
contractMetadata: ContractData,
|
contractMetadata: ContractData,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user