From d9fb14260ccb2191cf056085b7d2c149248c9b16 Mon Sep 17 00:00:00 2001 From: Daniyar Chambylov Date: Thu, 11 Apr 2019 16:06:19 +0600 Subject: [PATCH] Fix download compiler only once --- compat/truffle-compile/index.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/compat/truffle-compile/index.js b/compat/truffle-compile/index.js index 1977f89..e74bae2 100644 --- a/compat/truffle-compile/index.js +++ b/compat/truffle-compile/index.js @@ -339,20 +339,16 @@ compile.with_dependencies = async function(options, callback, compileAll) { filteredRequired = filteredRequired.filter(sourcePath => !sourcePath.endsWith('/Migrations.sol')) - let isSolcLoaded = false; + if (filteredRequired.length > 0) { + // Download solc compiler + const supplier = new CompilerSupplier(options.compilers.solc); + await supplier.load() + .catch(e => { + throw e; + }) + + } Promise.all(filteredRequired.map(async (sourcePath) => { - if (!isSolcLoaded) { - const supplier = new CompilerSupplier(options.compilers.solc); - await supplier - .load() - .then(solc => { - // do nothing - }) - .catch(e => { - throw e; - }) - isSolcLoaded = true; - } await new Promise((resolve, reject) => { Profiler.imported_sources( config.with({