Some checks failed
Test Action / Test with default inputs (push) Has been cancelled
Test Action / Test with default inputs-1 (push) Has been cancelled
Test Action / Test with default inputs-2 (push) Has been cancelled
Test Action / Test with explicit inputs (push) Has been cancelled
Test Action / Test with explicit inputs-1 (push) Has been cancelled
Test Action / Test with explicit inputs-2 (push) Has been cancelled
Test Action / Test with run_install (array, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (empty object, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (global, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (null, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (recursive, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (array, ubuntu-latest) (push) Has been cancelled
Test Action / Test with run_install (empty object, ubuntu-latest) (push) Has been cancelled
Test Action / Test with run_install (global, ubuntu-latest) (push) Has been cancelled
Test Action / Test with run_install (null, ubuntu-latest) (push) Has been cancelled
Test Action / Test with run_install (recursive, ubuntu-latest) (push) Has been cancelled
Test Action / Test with run_install (array, windows-latest) (push) Has been cancelled
Test Action / Test with run_install (empty object, windows-latest) (push) Has been cancelled
Test Action / Test with run_install (global, windows-latest) (push) Has been cancelled
Test Action / Test with run_install (null, windows-latest) (push) Has been cancelled
Test Action / Test with run_install (recursive, windows-latest) (push) Has been cancelled
39 lines
1 KiB
TypeScript
39 lines
1 KiB
TypeScript
import { getInput, error, InputOptions } from '@actions/core'
|
|
import Ajv from 'ajv'
|
|
import { load } from 'js-yaml'
|
|
import process from 'process'
|
|
import runInstallSchema from './run-install-input.schema.json'
|
|
|
|
export interface RunInstall {
|
|
readonly recursive?: boolean
|
|
readonly cwd?: string
|
|
readonly args?: readonly string[]
|
|
}
|
|
|
|
export type RunInstallInput =
|
|
| null
|
|
| boolean
|
|
| RunInstall
|
|
| RunInstall[]
|
|
|
|
const options: InputOptions = {
|
|
required: true,
|
|
}
|
|
|
|
export function parseRunInstall(name: string): RunInstall[] {
|
|
const result: RunInstallInput = load(getInput(name, options)) as any
|
|
const ajv = new Ajv({
|
|
allErrors: true,
|
|
})
|
|
const validate = ajv.compile(runInstallSchema)
|
|
if (!validate(result)) {
|
|
for (const errorItem of validate.errors!) {
|
|
error(`with.run_install${errorItem.dataPath}: ${errorItem.message}`)
|
|
}
|
|
return process.exit(1)
|
|
}
|
|
if (!result) return []
|
|
if (result === true) return [{ recursive: true }]
|
|
if (Array.isArray(result)) return result
|
|
return [result]
|
|
}
|