Husky commit correct node modules

This commit is contained in:
Timothy Clem
2019-09-23 19:56:26 -07:00
parent 1068d0618d
commit 241050c6d7
175 changed files with 13520 additions and 11 deletions

View File

@@ -20,23 +20,19 @@ const core = __importStar(require("@actions/core"));
const tc = __importStar(require("@actions/tool-cache"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
function cacheHaskell(installDir, tool) {
function cacheHaskellTool(installDir, tool) {
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 = semver.clean(v);
if (!version) {
continue;
}
core.debug(`found ${tool} version: ${version}`);
const dir = path.join(baseGHCDir, version);
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.cacheHaskell = cacheHaskell;
exports.cacheHaskellTool = cacheHaskellTool;
function findHaskellGHCVersion(version) {
return __awaiter(this, void 0, void 0, function* () {
return _findHaskellToolVersion('ghc', version);
@@ -51,6 +47,7 @@ function findHaskellCabalVersion(version) {
exports.findHaskellCabalVersion = findHaskellCabalVersion;
function _findHaskellToolVersion(tool, version) {
return __awaiter(this, void 0, void 0, function* () {
version = normalizeVersion(version);
const installDir = tc.find(tool, version);
if (!installDir) {
throw new Error(`Version ${version} of ${tool} not found`);
@@ -60,3 +57,18 @@ function _findHaskellToolVersion(tool, version) {
});
}
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

@@ -21,8 +21,8 @@ const installer_1 = require("./installer");
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
installer_1.cacheHaskell('/opt', 'ghc');
installer_1.cacheHaskell('/opt', 'cabal');
yield installer_1.cacheHaskellTool('/opt', 'ghc');
yield installer_1.cacheHaskellTool('/opt', 'cabal');
let ghcVersion = core.getInput('ghc-version');
yield installer_1.findHaskellGHCVersion(ghcVersion);
}