mirror of
https://code.forgejo.org/pnpm/action-setup.git
synced 2025-05-18 12:34:46 +00:00
Add run_install input
This commit is contained in:
parent
4b13327683
commit
d44b8c5e53
6 changed files with 67 additions and 1 deletions
|
@ -1,11 +1,25 @@
|
|||
import { getInput, InputOptions } from '@actions/core'
|
||||
import expandTilde from 'expand-tilde'
|
||||
import { safeLoad } from 'js-yaml'
|
||||
|
||||
interface RunInstall {
|
||||
readonly recursive?: boolean
|
||||
readonly cwd?: string
|
||||
readonly args?: readonly string[]
|
||||
}
|
||||
|
||||
type RunInstallInput =
|
||||
| null
|
||||
| boolean
|
||||
| RunInstall
|
||||
| RunInstall[]
|
||||
|
||||
export interface Inputs {
|
||||
readonly version: string
|
||||
readonly dest: string
|
||||
readonly binDest: string
|
||||
readonly registry: string
|
||||
readonly runInstall: RunInstall[]
|
||||
}
|
||||
|
||||
const options: InputOptions = {
|
||||
|
@ -14,11 +28,20 @@ const options: InputOptions = {
|
|||
|
||||
const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
||||
|
||||
function parseRunInstall(name: string): RunInstall[] {
|
||||
const result: RunInstallInput = safeLoad(getInput(name, options))
|
||||
if (!result) return []
|
||||
if (result === true) return [{ recursive: true }]
|
||||
if (Array.isArray(result)) return result
|
||||
return [result]
|
||||
}
|
||||
|
||||
export const getInputs = (): Inputs => ({
|
||||
version: getInput('version', options),
|
||||
dest: parseInputPath('dest'),
|
||||
binDest: parseInputPath('bin_dest'),
|
||||
registry: getInput('registry', options),
|
||||
runInstall: parseRunInstall('run_install'),
|
||||
})
|
||||
|
||||
export default getInputs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue