Convert to ESM

This commit is contained in:
Nick Alteen
2025-01-08 11:58:58 -05:00
parent f78d56ba70
commit 844440f60c
40 changed files with 33184 additions and 37099 deletions
+4 -3
View File
@@ -1,7 +1,8 @@
/**
* The entrypoint for the action.
* The entrypoint for the action. This file simply imports and runs the action's
* main logic.
*/
import { run } from './main'
import { run } from './main.js'
// eslint-disable-next-line @typescript-eslint/no-floating-promises
/* istanbul ignore next */
run()
+8 -11
View File
@@ -1,25 +1,22 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import { wait } from './wait'
import { wait } from './wait.js'
/**
* The main function for the action.
*
* @returns Resolves when the action is complete.
*/
export async function run(): Promise<void> {
try {
// Get the action input(s)
const ms: number = parseInt(core.getInput('milliseconds'), 10)
const ms: string = core.getInput('milliseconds')
// Output the payload for debugging
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
core.debug(
`The event payload: ${JSON.stringify(github.context.payload, null, 2)}`
)
core.debug(`Waiting ${ms} milliseconds ...`)
// Log the current timestamp, wait, then log the new timestamp
core.info(new Date().toTimeString())
await wait(ms)
core.info(new Date().toTimeString())
core.debug(new Date().toTimeString())
await wait(parseInt(ms, 10))
core.debug(new Date().toTimeString())
// Set outputs for other workflow steps to use
core.setOutput('time', new Date().toTimeString())
+6 -5
View File
@@ -1,11 +1,12 @@
/**
* Wait for a number of milliseconds. Resolves with 'done!' after the wait time.
* Waits for a number of milliseconds.
*
* @param milliseconds The number of milliseconds to wait.
* @returns Resolves with 'done!' after the wait is over.
*/
export async function wait(milliseconds: number): Promise<string> {
return new Promise(resolve => {
if (isNaN(milliseconds)) {
throw new Error('milliseconds not a number')
}
return new Promise((resolve) => {
if (isNaN(milliseconds)) throw new Error('milliseconds is not a number')
setTimeout(() => resolve('done!'), milliseconds)
})