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:
Shohei Ueda
2019-09-21 10:41:21 +09:00
committed by GitHub
parent 4d54b90c0e
commit dc8541739a
24 changed files with 924 additions and 168 deletions

38
src/index.ts Normal file
View 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();