2019-09-23 19:56:26 -07:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
|
import * as fs from 'fs';
|
|
|
|
|
import * as path from 'path';
|
|
|
|
|
|
2019-09-30 11:20:46 -07:00
|
|
|
export function findHaskellGHCVersion(baseInstallDir: string, version: string) {
|
2019-09-30 10:01:13 -07:00
|
|
|
return _findHaskellToolVersion(baseInstallDir, 'ghc', version);
|
2019-09-23 19:56:26 -07:00
|
|
|
}
|
|
|
|
|
|
2019-09-30 11:20:46 -07:00
|
|
|
export function findHaskellCabalVersion(
|
2019-09-30 10:01:13 -07:00
|
|
|
baseInstallDir: string,
|
|
|
|
|
version: string
|
|
|
|
|
) {
|
|
|
|
|
return _findHaskellToolVersion(baseInstallDir, 'cabal', version);
|
2019-09-23 19:56:26 -07:00
|
|
|
}
|
|
|
|
|
|
2019-09-30 11:20:46 -07:00
|
|
|
export function _findHaskellToolVersion(
|
2019-09-30 10:01:13 -07:00
|
|
|
baseInstallDir: string,
|
|
|
|
|
tool: string,
|
|
|
|
|
version: string
|
|
|
|
|
) {
|
|
|
|
|
if (!baseInstallDir) {
|
|
|
|
|
throw new Error('baseInstallDir parameter is required');
|
2019-09-23 19:56:26 -07:00
|
|
|
}
|
2019-09-30 10:01:13 -07:00
|
|
|
if (!tool) {
|
|
|
|
|
throw new Error('toolName parameter is required');
|
2019-09-23 19:56:26 -07:00
|
|
|
}
|
2019-09-30 10:01:13 -07:00
|
|
|
if (!version) {
|
|
|
|
|
throw new Error('versionSpec parameter is required');
|
2019-09-23 19:56:26 -07:00
|
|
|
}
|
|
|
|
|
|
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 11:20:46 -07:00
|
|
|
// if (fs.existsSync(toolPath)) {
|
|
|
|
|
// core.debug(`Found tool in cache ${tool} ${version}`);
|
|
|
|
|
// core.addPath(toolPath);
|
|
|
|
|
// } else {
|
|
|
|
|
// throw new Error(`Version ${version} of ${tool} not found`);
|
|
|
|
|
// }
|
2019-09-23 19:56:26 -07:00
|
|
|
}
|