From 0ab446a68dd262eeb944a89a5bc0fbff314be164 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Mon, 16 Nov 2020 11:23:35 -0500 Subject: [PATCH] get chocoPathVersion Correctly --- dist/index.js | 11 ++++++++--- src/installer.ts | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 3761b1b..6a38fd9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11078,7 +11078,12 @@ async function isInstalled(tool, version, os) { const ghcupPath = `${process.env.HOME}/.ghcup${tool === 'ghc' ? `/ghc/${version}` : ''}/bin`; const v = tool === 'cabal' ? version.slice(0, 3) : version; const aptPath = `/opt/${tool}/${v}/bin`; - const chocoPath = path_1.join(`${process.env.ChocolateyInstall}`, 'lib', `${tool}.${version}`, 'tools', `${tool}-${version}`, tool === 'ghc' ? 'bin' : ''); + const chocoPathArray = version.split('.'); + const chocoPathVersion = chocoPathArray.length > 3 + ? chocoPathArray.slice(0, chocoPathArray.length - 1).join('.') + : chocoPathArray.join('.'); + const chocoPath = path_1.join(`${process.env.ChocolateyInstall}`, 'lib', `${tool}.${version}`, 'tools', tool === 'ghc' ? `${tool}-${chocoPathVersion}` : `${tool}-${version}`, // choco trims the ghc version here + tool === 'ghc' ? 'bin' : ''); const locations = { stack: [], cabal: { @@ -11184,8 +11189,8 @@ async function choco(tool, version) { ignoreReturnCode: true }); // Manually add the path because it won't happen until the end of the step normally - let pathArray = version.split('.'); - let pathVersion = pathArray.length > 3 + const pathArray = version.split('.'); + const pathVersion = pathArray.length > 3 ? pathArray.slice(0, pathArray.length - 1).join('.') : pathArray.join('.'); const chocoPath = path_1.join(`${process.env.ChocolateyInstall}`, 'lib', `${tool}.${version}`, 'tools', tool === 'ghc' ? `${tool}-${pathVersion}` : `${tool}-${version}`, // choco trims the ghc version here diff --git a/src/installer.ts b/src/installer.ts index efe8725..0750251 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -56,12 +56,17 @@ async function isInstalled( const v = tool === 'cabal' ? version.slice(0, 3) : version; const aptPath = `/opt/${tool}/${v}/bin`; + const chocoPathArray = version.split('.'); + const chocoPathVersion = + chocoPathArray.length > 3 + ? chocoPathArray.slice(0, chocoPathArray.length - 1).join('.') + : chocoPathArray.join('.'); const chocoPath = join( `${process.env.ChocolateyInstall}`, 'lib', `${tool}.${version}`, 'tools', - `${tool}-${version}`, + tool === 'ghc' ? `${tool}-${chocoPathVersion}` : `${tool}-${version}`, // choco trims the ghc version here tool === 'ghc' ? 'bin' : '' );