|
1 | 1 | // FIXME: https://github.com/actions/toolkit/issues/1959 |
2 | 2 | // import { getMultilineInput } from '@actions/core' |
3 | | -import { getMultilineInput } from './tool' |
| 3 | + |
| 4 | +/** |
| 5 | + * Interface for getInput options |
| 6 | + */ |
| 7 | +export interface InputOptions { |
| 8 | + /** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */ |
| 9 | + required?: boolean |
| 10 | + |
| 11 | + /** Optional. Whether leading/trailing whitespace will be trimmed for the input. Defaults to true */ |
| 12 | + trimWhitespace?: boolean |
| 13 | +} |
| 14 | +/** |
| 15 | + * Gets the value of an input. |
| 16 | + * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. |
| 17 | + * Returns an empty string if the value is not defined. |
| 18 | + * |
| 19 | + * @param name name of the input to get |
| 20 | + * @param options optional. See InputOptions. |
| 21 | + * @returns string |
| 22 | + */ |
| 23 | +export function getInput(name: string, options?: InputOptions): string { |
| 24 | + const val: string = |
| 25 | + process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '' |
| 26 | + if (options && options.required && !val) { |
| 27 | + throw new Error(`Input required and not supplied: ${name}`) |
| 28 | + } |
| 29 | + |
| 30 | + if (options && options.trimWhitespace === false) { |
| 31 | + return val |
| 32 | + } |
| 33 | + |
| 34 | + return val.trim() |
| 35 | +} |
| 36 | +/** |
| 37 | + * Gets the values of an multiline input. Each value is also trimmed. |
| 38 | + * |
| 39 | + * @param name name of the input to get |
| 40 | + * @param options optional. See InputOptions. |
| 41 | + * @returns string[] |
| 42 | + */ |
| 43 | + |
| 44 | +export function getMultilineInput( |
| 45 | + name: string, |
| 46 | + options?: InputOptions, |
| 47 | +): string[] { |
| 48 | + const inputs: string[] = getInput(name, options) |
| 49 | + .replaceAll(",", "\n") |
| 50 | + .split('\n') |
| 51 | + .filter((x) => x !== '') |
| 52 | + |
| 53 | + if (options && options.trimWhitespace === false) { |
| 54 | + return inputs |
| 55 | + } |
| 56 | + |
| 57 | + return inputs.map((input) => input.trim()) |
| 58 | +} |
| 59 | + |
| 60 | + |
4 | 61 | import { install } from '@easy-install/easy-install' |
5 | 62 | import { version } from '../package.json' |
| 63 | +import { exec } from 'child_process' |
6 | 64 |
|
7 | 65 | const urlList = getMultilineInput('url') |
8 | | -const nameList = getMultilineInput('name') |
9 | 66 |
|
10 | 67 | async function main() { |
11 | 68 | console.log(`easy-setup: ${version}`) |
12 | 69 | console.log(`nodejs: ${process.version}`); |
13 | 70 | for (let i = 0; i < urlList.length; i++) { |
14 | 71 | const url = urlList[i] |
15 | | - const name = nameList[i] |
16 | | - await install(url, name) |
| 72 | + exec(`ei ${url}`, ) |
17 | 73 | } |
18 | 74 | } |
19 | 75 |
|
|
0 commit comments