Skip to content

Commit

Permalink
fix(VKUI patch): getBooleanInput fix required
Browse files Browse the repository at this point in the history
Исправленная версия getBooleanInput функции из `@actions/core`

- actions/toolkit#844
  • Loading branch information
SevereCloud committed Sep 6, 2023
1 parent d0c72f0 commit 63b1d6c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions VKUI/patch/src/getBooleanInput.ts
@@ -0,0 +1,22 @@
import * as core from '@actions/core';

const trueValue = ['true', 'True', 'TRUE'];
const falseValue = ['false', 'False', 'FALSE'];

/**
* Исправленная версия getBooleanInput функции из `@actions/core`.
*
* [getBooleanInput ignores options.required](https://github.com/actions/toolkit/issues/844)
*/
export function getBooleanInput(name: string, options?: core.InputOptions): boolean {
const val = core.getInput(name, options);

if (!val) return false;
if (trueValue.includes(val)) return true;
if (falseValue.includes(val)) return false;

throw new TypeError(
`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``,
);
}
3 changes: 2 additions & 1 deletion VKUI/patch/src/main.ts
Expand Up @@ -7,6 +7,7 @@ import { SemVer } from 'semver';
import { getPatchInstructions } from './message';
import { getMergeData } from './getMergeData';
import { stableBranchName } from './stableBranchName';
import { getBooleanInput } from './getBooleanInput';

function getPrNumber() {
const pullRequest = github.context.payload.pull_request;
Expand Down Expand Up @@ -49,7 +50,7 @@ async function run(): Promise<void> {
const token = core.getInput('token', { required: true });
const directory = core.getInput('directory');
const targetBranchInput = core.getInput('targetBranch');
const needScreenshots = core.getBooleanInput('needScreenshots');
const needScreenshots = getBooleanInput('needScreenshots');
const pullNumber = getPrNumber();

const gh = github.getOctokit(token);
Expand Down

0 comments on commit 63b1d6c

Please sign in to comment.