mirror of
https://code.forgejo.org/pnpm/action-setup.git
synced 2025-05-17 12:24:45 +00:00
Support tilde
This commit is contained in:
parent
fe1f80eaca
commit
59a67d7671
5 changed files with 40 additions and 50 deletions
|
@ -1,6 +1,5 @@
|
|||
import { inspect } from 'util'
|
||||
import { getInput, error, InputOptions } from '@actions/core'
|
||||
import * as glob from '@actions/glob'
|
||||
import { getInput, InputOptions } from '@actions/core'
|
||||
import expandTilde from 'expand-tilde'
|
||||
|
||||
export interface Inputs {
|
||||
readonly version: string
|
||||
|
@ -13,22 +12,12 @@ const options: InputOptions = {
|
|||
required: true,
|
||||
}
|
||||
|
||||
async function parsePath(pattern: string, inputName: string) {
|
||||
const builder = await glob.create(pattern)
|
||||
const paths = await builder.glob()
|
||||
if (paths.length !== 1) {
|
||||
error(`Input ${inputName} is expected to match 1 path, but it matches ${paths.length}: ${inspect(paths)}`)
|
||||
throw process.exit(1)
|
||||
}
|
||||
return paths[0]
|
||||
}
|
||||
const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
||||
|
||||
const parseInputPath = (name: string) => parsePath(getInput(name, options), name)
|
||||
|
||||
export const getInputs = async (): Promise<Inputs> => ({
|
||||
export const getInputs = (): Inputs => ({
|
||||
version: getInput('version', options),
|
||||
dest: await parseInputPath('dest'),
|
||||
binDest: await parseInputPath('bin_dest'),
|
||||
dest: parseInputPath('dest'),
|
||||
binDest: parseInputPath('bin_dest'),
|
||||
registry: getInput('registry', options),
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue