mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-25 04:12:17 +01:00
Feat: Support macOS and Windows, migrate JavaScript to TypeScript (#32)
- Support macOS and Windows (Close #24 ) - Refactoring - Error handling - TypeScript - Prettier (Close #29 ) - GHA: Add upload-artifact step for test coverage - deps: Install husky
This commit is contained in:
38
src/index.ts
Normal file
38
src/index.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import getLatestVersion from './get-latest-version';
|
||||
import installer from './installer';
|
||||
|
||||
// most @actions toolkit packages have async methods
|
||||
async function run() {
|
||||
const dump = async () => {
|
||||
// Show version
|
||||
await exec.exec('hugo version');
|
||||
await exec.exec('go version');
|
||||
await exec.exec('git --version');
|
||||
};
|
||||
|
||||
try {
|
||||
const hugoVersion: string = core.getInput('hugo-version');
|
||||
console.log(`Hugo version: ${hugoVersion}`);
|
||||
|
||||
if (hugoVersion === '' || hugoVersion === 'latest') {
|
||||
getLatestVersion().then(
|
||||
async function(latestVersion): Promise<void> {
|
||||
await installer(latestVersion);
|
||||
await dump();
|
||||
},
|
||||
function(error) {
|
||||
core.setFailed(error);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
await installer(hugoVersion);
|
||||
await dump();
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user