mirror of
https://github.com/pnpm/action-setup.git
synced 2024-11-13 21:33:57 +00:00
Move run-install to its own module
This commit is contained in:
parent
91d3d73121
commit
6fe65dc1af
BIN
dist/index.js
vendored
BIN
dist/index.js
vendored
Binary file not shown.
@ -1,21 +1,6 @@
|
||||
import process from 'process'
|
||||
import { getInput, error, InputOptions } from '@actions/core'
|
||||
import { getInput, InputOptions } from '@actions/core'
|
||||
import expandTilde from 'expand-tilde'
|
||||
import { safeLoad } from 'js-yaml'
|
||||
import Ajv from 'ajv'
|
||||
import runInstallSchema from './run-install-input.schema.json'
|
||||
|
||||
interface RunInstall {
|
||||
readonly recursive?: boolean
|
||||
readonly cwd?: string
|
||||
readonly args?: readonly string[]
|
||||
}
|
||||
|
||||
export type RunInstallInput =
|
||||
| null
|
||||
| boolean
|
||||
| RunInstall
|
||||
| RunInstall[]
|
||||
import { RunInstall, parseRunInstall } from './run-install'
|
||||
|
||||
export interface Inputs {
|
||||
readonly version: string
|
||||
@ -31,25 +16,6 @@ const options: InputOptions = {
|
||||
|
||||
const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
||||
|
||||
function parseRunInstall(name: string): RunInstall[] {
|
||||
const result: RunInstallInput = safeLoad(getInput(name, options))
|
||||
const ajv = new Ajv({
|
||||
allErrors: true,
|
||||
async: false,
|
||||
})
|
||||
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]
|
||||
}
|
||||
|
||||
export const getInputs = (): Inputs => ({
|
||||
version: getInput('version', options),
|
||||
dest: parseInputPath('dest'),
|
||||
|
@ -14,7 +14,7 @@
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"input": "index.ts",
|
||||
"input": "run-install.ts",
|
||||
"symbol": "RunInstallInput",
|
||||
"output": "run-install-input.schema.json"
|
||||
}
|
||||
|
40
src/inputs/run-install.ts
Normal file
40
src/inputs/run-install.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import process from 'process'
|
||||
import { safeLoad } from 'js-yaml'
|
||||
import Ajv from 'ajv'
|
||||
import { getInput, error, InputOptions } from '@actions/core'
|
||||
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 = safeLoad(getInput(name, options))
|
||||
const ajv = new Ajv({
|
||||
allErrors: true,
|
||||
async: false,
|
||||
})
|
||||
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]
|
||||
}
|
Loading…
Reference in New Issue
Block a user