Updated node_mobules from what huskey wants to do

This commit is contained in:
Timothy Clem
2019-09-30 10:02:47 -07:00
parent a7a93607c6
commit caa2e9e5b6
7412 changed files with 26 additions and 1868293 deletions

View File

@@ -17,58 +17,39 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const tc = __importStar(require("@actions/tool-cache"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
function cacheHaskellTool(installDir, tool) {
function findHaskellGHCVersion(baseInstallDir, version) {
return __awaiter(this, void 0, void 0, function* () {
const baseGHCDir = path.join(installDir, tool);
const versions = fs.readdirSync(baseGHCDir);
for (const v of versions) {
const version = normalizeVersion(v);
core.debug(`found ${tool} version: ${v} normalized to ${version}`);
const dir = path.join(baseGHCDir, v);
yield tc.cacheDir(dir, tool, version);
}
});
}
exports.cacheHaskellTool = cacheHaskellTool;
function findHaskellGHCVersion(version) {
return __awaiter(this, void 0, void 0, function* () {
return _findHaskellToolVersion('ghc', version);
return _findHaskellToolVersion(baseInstallDir, 'ghc', version);
});
}
exports.findHaskellGHCVersion = findHaskellGHCVersion;
function findHaskellCabalVersion(version) {
function findHaskellCabalVersion(baseInstallDir, version) {
return __awaiter(this, void 0, void 0, function* () {
return _findHaskellToolVersion('cabal', version);
return _findHaskellToolVersion(baseInstallDir, 'cabal', version);
});
}
exports.findHaskellCabalVersion = findHaskellCabalVersion;
function _findHaskellToolVersion(tool, version) {
function _findHaskellToolVersion(baseInstallDir, tool, version) {
return __awaiter(this, void 0, void 0, function* () {
version = normalizeVersion(version);
const installDir = tc.find(tool, version);
if (!installDir) {
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');
}
const toolPath = path.join(baseInstallDir, tool, version, 'bin');
if (fs.existsSync(toolPath) && fs.existsSync(`${toolPath}.complete`)) {
core.debug(`Found tool in cache ${tool} ${version}`);
}
else {
throw new Error(`Version ${version} of ${tool} not found`);
}
const toolPath = path.join(installDir, 'bin');
core.addPath(toolPath);
});
}
exports._findHaskellToolVersion = _findHaskellToolVersion;
// This function is required to convert the version 1.10 to 1.10.0.
// Because caching utility accept only sementic version,
// which have patch number as well.
function normalizeVersion(version) {
const versionPart = version.split('.');
if (versionPart[1] == null) {
//append minor and patch version if not available
return version.concat('.0.0');
}
if (versionPart[2] == null) {
//append patch version if not available
return version.concat('.0');
}
return version;
}

View File

@@ -18,23 +18,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const installer_1 = require("./installer");
// ghc and cabal are installed directly to /opt so use that directlly instead of
// copying over to the toolcache dir.
const baseInstallDir = '/opt';
const defaultGHCVersion = '8.6.5';
const defualtCabalVersion = '3.0';
const defaultCabalVersion = '3.0';
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield installer_1.cacheHaskellTool('/opt', 'ghc');
yield installer_1.cacheHaskellTool('/opt', 'cabal');
let ghcVersion = core.getInput('ghc-version');
if (!ghcVersion) {
ghcVersion = defaultGHCVersion;
}
yield installer_1.findHaskellGHCVersion(ghcVersion);
yield installer_1.findHaskellGHCVersion(baseInstallDir, ghcVersion);
let cabalVersion = core.getInput('cabal-version');
if (!cabalVersion) {
cabalVersion = defualtCabalVersion;
cabalVersion = defaultCabalVersion;
}
yield installer_1.findHaskellCabalVersion(cabalVersion);
yield installer_1.findHaskellCabalVersion(baseInstallDir, cabalVersion);
}
catch (error) {
core.setFailed(error.message);