Initial migration on TS

This commit is contained in:
Borales
2022-11-26 21:54:41 +01:00
parent fdf0082f89
commit 6bc995441e
17 changed files with 5994 additions and 46 deletions
+20
View File
@@ -0,0 +1,20 @@
import {debug, getInput, setOutput, setFailed} from '@actions/core'
import {ensureYarnIsInstalled} from './yarn'
import {run} from './run'
const main = async () => {
await ensureYarnIsInstalled()
const cmd: string = getInput('cmd', {required: true})
try {
debug(`Running "${cmd}" command`)
await run(cmd)
setOutput(cmd, 'Done')
} catch (error) {
if (error instanceof Error) setFailed(error.message)
}
}
main()
+5
View File
@@ -0,0 +1,5 @@
import {exec} from '@actions/exec'
export const run = async (cmd: string) => {
await exec('yarn', [cmd])
}
+18
View File
@@ -0,0 +1,18 @@
import {debug} from '@actions/core'
import {exec, getExecOutput} from '@actions/exec'
import {which} from '@actions/io'
export const ensureYarnIsInstalled = async () => {
try {
await which('yarn', true)
} catch (e) {
await exec('npm install --global yarn')
}
const [{stdout: yarnVersion}, {stdout: nodeVersion}] = await Promise.all([
getExecOutput('yarn', ['--version'], {silent: true}),
getExecOutput('node', ['--version'], {silent: true})
])
debug(`Node ${nodeVersion.trim()} detected`)
debug(`Yarn v${yarnVersion.trim()} detected`)
}