diff options
author | F. Eugene Aumson <gene@aumson.org> | 2018-08-16 07:14:36 +0800 |
---|---|---|
committer | F. Eugene Aumson <gene@aumson.org> | 2018-08-16 08:22:35 +0800 |
commit | badcb35525a4ccd5c80b7ad79288b267b961faef (patch) | |
tree | 28a249430af808559e90f193900d4715408c6f6f /packages | |
parent | 89202b7bdffe084511971e331f81dd5878f2a56c (diff) | |
download | dexon-sol-tools-badcb35525a4ccd5c80b7ad79288b267b961faef.tar dexon-sol-tools-badcb35525a4ccd5c80b7ad79288b267b961faef.tar.gz dexon-sol-tools-badcb35525a4ccd5c80b7ad79288b267b961faef.tar.bz2 dexon-sol-tools-badcb35525a4ccd5c80b7ad79288b267b961faef.tar.lz dexon-sol-tools-badcb35525a4ccd5c80b7ad79288b267b961faef.tar.xz dexon-sol-tools-badcb35525a4ccd5c80b7ad79288b267b961faef.tar.zst dexon-sol-tools-badcb35525a4ccd5c80b7ad79288b267b961faef.zip |
extract method _shouldCompile()
Diffstat (limited to 'packages')
-rw-r--r-- | packages/sol-compiler/src/compiler.ts | 25 |
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, |