2019-09-21 01:41:21 +00:00
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
var result = {};
|
|
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
|
|
result["default"] = mod;
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const core = __importStar(require("@actions/core"));
|
|
|
|
const exec = __importStar(require("@actions/exec"));
|
|
|
|
const get_latest_version_1 = __importDefault(require("./get-latest-version"));
|
|
|
|
const installer_1 = __importDefault(require("./installer"));
|
2019-09-15 23:27:57 +00:00
|
|
|
// most @actions toolkit packages have async methods
|
2019-09-21 01:41:21 +00:00
|
|
|
function run() {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
const dump = () => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
// Show version
|
|
|
|
yield exec.exec('hugo version');
|
|
|
|
});
|
|
|
|
try {
|
|
|
|
const hugoVersion = core.getInput('hugo-version');
|
|
|
|
console.log(`Hugo version: ${hugoVersion}`);
|
|
|
|
if (hugoVersion === '' || hugoVersion === 'latest') {
|
|
|
|
get_latest_version_1.default().then(function (latestVersion) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
yield installer_1.default(latestVersion);
|
|
|
|
yield dump();
|
|
|
|
});
|
|
|
|
}, function (error) {
|
|
|
|
core.setFailed(error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
yield installer_1.default(hugoVersion);
|
|
|
|
yield dump();
|
|
|
|
}
|
2019-09-17 19:11:47 +00:00
|
|
|
}
|
2019-09-21 01:41:21 +00:00
|
|
|
catch (error) {
|
|
|
|
core.setFailed(error.message);
|
2019-09-17 19:11:47 +00:00
|
|
|
}
|
2019-09-21 01:41:21 +00:00
|
|
|
});
|
2019-09-15 23:27:57 +00:00
|
|
|
}
|
|
|
|
run();
|