mirror of
https://github.com/actions/typescript-action.git
synced 2025-12-13 21:51:53 +00:00
Update typescript template to follow some conventions (#42)
* Update default project to follow conventions
This commit is contained in:
20
src/main.ts
20
src/main.ts
@@ -1,19 +1,19 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as core from '@actions/core'
|
||||
import {wait} from './wait'
|
||||
|
||||
async function run() {
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const ms = core.getInput('milliseconds');
|
||||
console.log(`Waiting ${ms} milliseconds ...`)
|
||||
const ms: string = core.getInput('milliseconds')
|
||||
core.debug(`Waiting ${ms} milliseconds ...`)
|
||||
|
||||
core.debug((new Date()).toTimeString())
|
||||
await wait(parseInt(ms, 10));
|
||||
core.debug((new Date()).toTimeString())
|
||||
core.debug(new Date().toTimeString())
|
||||
await wait(parseInt(ms, 10))
|
||||
core.debug(new Date().toTimeString())
|
||||
|
||||
core.setOutput('time', new Date().toTimeString());
|
||||
core.setOutput('time', new Date().toTimeString())
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
run()
|
||||
|
||||
15
src/wait.ts
15
src/wait.ts
@@ -1,10 +1,9 @@
|
||||
export function wait(milliseconds: number) {
|
||||
return new Promise((resolve) => {
|
||||
if (isNaN(milliseconds)) {
|
||||
throw new Error('milliseconds not a number');
|
||||
}
|
||||
export async function wait(milliseconds: number): Promise<string> {
|
||||
return new Promise(resolve => {
|
||||
if (isNaN(milliseconds)) {
|
||||
throw new Error('milliseconds not a number')
|
||||
}
|
||||
|
||||
setTimeout(() => resolve("done!"), milliseconds)
|
||||
});
|
||||
setTimeout(() => resolve('done!'), milliseconds)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user