update with tests

This commit is contained in:
Bryan MacFarlane
2019-09-21 08:56:30 -04:00
parent 6c7859e4c8
commit b2a87e0a71
10 changed files with 218 additions and 35 deletions

View File

@@ -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
View 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)
});
}