Files
setup-haskell/src/installer.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

import * as core from '@actions/core';
import * as fs from 'fs';
import * as path from 'path';
export async function findHaskellGHCVersion(
baseInstallDir: string,
version: string
) {
return _findHaskellToolVersion(baseInstallDir, 'ghc', version);
}
export async function findHaskellCabalVersion(
baseInstallDir: string,
version: string
) {
return _findHaskellToolVersion(baseInstallDir, 'cabal', version);
}
export async function _findHaskellToolVersion(
baseInstallDir: string,
tool: string,
version: string
) {
if (!baseInstallDir) {
throw new Error('baseInstallDir parameter is required');
}
if (!tool) {
throw new Error('toolName parameter is required');
}
if (!version) {
throw new Error('versionSpec parameter is required');
}
2019-09-30 10:40:10 -07:00
const toolPath: string = path.join(baseInstallDir, tool, version, 'bin');
2019-09-30 11:12:07 -07:00
throw new Error(`Looking in ${toolPath}`);
2019-09-30 10:38:50 -07:00
if (fs.existsSync(toolPath)) {
core.debug(`Found tool in cache ${tool} ${version}`);
2019-09-30 10:38:50 -07:00
core.addPath(toolPath);
} else {
throw new Error(`Version ${version} of ${tool} not found`);
}
}