Convert to ESM

This commit is contained in:
Nick Alteen
2024-11-15 11:44:18 -05:00
parent d6b1edd724
commit 970fe4ae16
13 changed files with 2632 additions and 316 deletions

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()

View File

@@ -1,9 +1,10 @@
import * as core from '@actions/core'
import { wait } from './wait'
import { wait } from './wait.js'
/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
*
* @returns Resolves when the action is complete.
*/
export async function run(): Promise<void> {
try {

View File

@@ -1,13 +1,12 @@
/**
* Wait for a number of milliseconds.
* Waits for a number of milliseconds.
*
* @param milliseconds The number of milliseconds to wait.
* @returns {Promise<string>} Resolves with 'done!' after the wait is over.
* @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)
})