refactor getChocoPath
This commit is contained in:
27
dist/index.js
vendored
27
dist/index.js
vendored
@@ -11078,12 +11078,7 @@ async function isInstalled(tool, version, os) {
|
|||||||
const ghcupPath = `${process.env.HOME}/.ghcup${tool === 'ghc' ? `/ghc/${version}` : ''}/bin`;
|
const ghcupPath = `${process.env.HOME}/.ghcup${tool === 'ghc' ? `/ghc/${version}` : ''}/bin`;
|
||||||
const v = tool === 'cabal' ? version.slice(0, 3) : version;
|
const v = tool === 'cabal' ? version.slice(0, 3) : version;
|
||||||
const aptPath = `/opt/${tool}/${v}/bin`;
|
const aptPath = `/opt/${tool}/${v}/bin`;
|
||||||
const chocoPathArray = version.split('.');
|
const chocoPath = getChocoPath(tool, version);
|
||||||
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 = {
|
const locations = {
|
||||||
stack: [],
|
stack: [],
|
||||||
cabal: {
|
cabal: {
|
||||||
@@ -11188,14 +11183,8 @@ async function choco(tool, version) {
|
|||||||
], {
|
], {
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
});
|
});
|
||||||
// Manually add the path because it won't happen until the end of the step normally
|
// Add to path automatically because it does not add until the end of the step.
|
||||||
const pathArray = version.split('.');
|
core.addPath(getChocoPath(tool, version));
|
||||||
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
|
|
||||||
tool === 'ghc' ? 'bin' : '');
|
|
||||||
core.addPath(chocoPath);
|
|
||||||
}
|
}
|
||||||
async function ghcupBin(os) {
|
async function ghcupBin(os) {
|
||||||
const v = '0.1.8';
|
const v = '0.1.8';
|
||||||
@@ -11215,6 +11204,16 @@ async function ghcup(tool, version, os) {
|
|||||||
if (returnCode === 0 && tool === 'ghc')
|
if (returnCode === 0 && tool === 'ghc')
|
||||||
await exec_1.exec(bin, ['set', version]);
|
await exec_1.exec(bin, ['set', version]);
|
||||||
}
|
}
|
||||||
|
function getChocoPath(tool, version) {
|
||||||
|
// Manually add the path because it won't happen until the end of the step normally
|
||||||
|
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
|
||||||
|
tool === 'ghc' ? 'bin' : '');
|
||||||
|
return chocoPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
@@ -56,19 +56,7 @@ async function isInstalled(
|
|||||||
const v = tool === 'cabal' ? version.slice(0, 3) : version;
|
const v = tool === 'cabal' ? version.slice(0, 3) : version;
|
||||||
const aptPath = `/opt/${tool}/${v}/bin`;
|
const aptPath = `/opt/${tool}/${v}/bin`;
|
||||||
|
|
||||||
const chocoPathArray = version.split('.');
|
const chocoPath = getChocoPath(tool, version);
|
||||||
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 === 'ghc' ? `${tool}-${chocoPathVersion}` : `${tool}-${version}`, // choco trims the ghc version here
|
|
||||||
tool === 'ghc' ? 'bin' : ''
|
|
||||||
);
|
|
||||||
|
|
||||||
const locations = {
|
const locations = {
|
||||||
stack: [], // Always installed into the tool cache
|
stack: [], // Always installed into the tool cache
|
||||||
@@ -191,21 +179,8 @@ async function choco(tool: Tool, version: string): Promise<void> {
|
|||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// Manually add the path because it won't happen until the end of the step normally
|
// Add to path automatically because it does not add until the end of the step.
|
||||||
const pathArray = version.split('.');
|
core.addPath(getChocoPath(tool, version));
|
||||||
const pathVersion =
|
|
||||||
pathArray.length > 3
|
|
||||||
? pathArray.slice(0, pathArray.length - 1).join('.')
|
|
||||||
: pathArray.join('.');
|
|
||||||
const chocoPath = join(
|
|
||||||
`${process.env.ChocolateyInstall}`,
|
|
||||||
'lib',
|
|
||||||
`${tool}.${version}`,
|
|
||||||
'tools',
|
|
||||||
tool === 'ghc' ? `${tool}-${pathVersion}` : `${tool}-${version}`, // choco trims the ghc version here
|
|
||||||
tool === 'ghc' ? 'bin' : ''
|
|
||||||
);
|
|
||||||
core.addPath(chocoPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ghcupBin(os: OS): Promise<string> {
|
async function ghcupBin(os: OS): Promise<string> {
|
||||||
@@ -234,3 +209,21 @@ async function ghcup(tool: Tool, version: string, os: OS): Promise<void> {
|
|||||||
);
|
);
|
||||||
if (returnCode === 0 && tool === 'ghc') await exec(bin, ['set', version]);
|
if (returnCode === 0 && tool === 'ghc') await exec(bin, ['set', version]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getChocoPath(tool: Tool, version: string): string {
|
||||||
|
// Manually add the path because it won't happen until the end of the step normally
|
||||||
|
const pathArray = version.split('.');
|
||||||
|
const pathVersion =
|
||||||
|
pathArray.length > 3
|
||||||
|
? pathArray.slice(0, pathArray.length - 1).join('.')
|
||||||
|
: pathArray.join('.');
|
||||||
|
const chocoPath = join(
|
||||||
|
`${process.env.ChocolateyInstall}`,
|
||||||
|
'lib',
|
||||||
|
`${tool}.${version}`,
|
||||||
|
'tools',
|
||||||
|
tool === 'ghc' ? `${tool}-${pathVersion}` : `${tool}-${version}`, // choco trims the ghc version here
|
||||||
|
tool === 'ghc' ? 'bin' : ''
|
||||||
|
);
|
||||||
|
return chocoPath;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user