From 92ae5c49b328c70da048823ae4932c2ce6c74ad0 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 30 Jun 2021 17:57:42 +0530 Subject: [PATCH] handle error for solc-select --- libs/remixd/src/services/slitherClient.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libs/remixd/src/services/slitherClient.ts b/libs/remixd/src/services/slitherClient.ts index bb0f85e79e..926305034d 100644 --- a/libs/remixd/src/services/slitherClient.ts +++ b/libs/remixd/src/services/slitherClient.ts @@ -67,16 +67,21 @@ export class SlitherClient extends PluginClient { // Get compiler version without commit id e.g: 0.8.2 const version: string = versionString.substring(0, versionString.indexOf('+commit')) // List solc versions installed using solc-select - const solcSelectInstalledVersions: Buffer = execSync('solc-select versions', options) - // Check if required version is already installed - if (!solcSelectInstalledVersions.toString().includes(version)) { - console.log('\x1b[32m%s\x1b[0m', `[Slither Analysis]: Installing ${version} using solc-select`) - // Install required version - execSync(`solc-select install ${version}`, options) + try { + const solcSelectInstalledVersions: Buffer = execSync('solc-select versions', options) + // Check if required version is already installed + if (!solcSelectInstalledVersions.toString().includes(version)) { + console.log('\x1b[32m%s\x1b[0m', `[Slither Analysis]: Installing ${version} using solc-select`) + // Install required version + execSync(`solc-select install ${version}`, options) + } + console.log('\x1b[32m%s\x1b[0m', `[Slither Analysis]: Setting ${version} as current solc version using solc-select`) + // Set solc current version as required version + execSync(`solc-select use ${version}`, options) + } catch (err) { + console.log(err) + reject(new Error('Error in running solc-select command')) } - console.log('\x1b[32m%s\x1b[0m', `[Slither Analysis]: Setting ${version} as current solc version using solc-select`) - // Set solc current version as required version - execSync(`solc-select use ${version}`, options) } else console.log('\x1b[32m%s\x1b[0m', '[Slither Analysis]: Compiler version is same as installed solc version') } const outputFile: string = 'remix-slitherReport_' + Date.now() + '.json'