mirror of
https://github.com/actions/typescript-action.git
synced 2025-12-20 06:56:35 +00:00
update with tests
This commit is contained in:
11
src/main.ts
11
src/main.ts
@@ -1,9 +1,16 @@
|
||||
import * as core from '@actions/core';
|
||||
import {wait} from './wait'
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const myInput = core.getInput('myInput');
|
||||
core.debug(`Hello ${myInput}`);
|
||||
const ms = core.getInput('milliseconds');
|
||||
console.log(`Waiting ${ms} milliseconds ...`)
|
||||
|
||||
core.debug((new Date()).toTimeString())
|
||||
wait(parseInt(ms));
|
||||
core.debug((new Date()).toTimeString())
|
||||
|
||||
core.setOutput('time', new Date().toTimeString());
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
||||
10
src/wait.ts
Normal file
10
src/wait.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export function wait(milliseconds) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof(milliseconds) !== 'number') {
|
||||
throw new Error('milleseconds not a number');
|
||||
}
|
||||
|
||||
setTimeout(() => resolve("done!"), milliseconds)
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user