Skip to content

Commit

Permalink
Merge pull request #287 from shogo82148/introduce-core-getBooleanInput
Browse files Browse the repository at this point in the history
use core.getBooleanInput instead of original one
  • Loading branch information
shogo82148 committed May 22, 2021
2 parents 988c532 + ddea021 commit 83d4ed0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 45 deletions.
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -12,7 +12,7 @@ inputs:
required: true
auto-start:
description: enable to auto-start redis-sever
default: "yes"
default: "true"
required: true
runs:
using: 'node12'
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -22,7 +22,7 @@
"author": "Ichinose Shogo",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.7",
"@actions/core": "^1.3.0",
"@actions/exec": "^1.0.4",
"@actions/io": "^1.1.0",
"@actions/tool-cache": "^1.6.1",
Expand Down
40 changes: 4 additions & 36 deletions src/setup-redis.ts
Expand Up @@ -4,19 +4,10 @@ import * as starter from './starter';

async function run() {
try {
const version = core.getInput('redis-version', {
required: true
});
const port = parseInt(
core.getInput('redis-port', {
required: true
})
);
const autoStart = parseBoolean(
core.getInput('auto-start', {
required: true
})
);
const required = {required: true};
const version = core.getInput('redis-version', required);
const port = parseInt(core.getInput('redis-port', required));
const autoStart = core.getBooleanInput('auto-start', required);

const redisPath = await core.group('install redis', async () => {
return installer.getRedis(version);
Expand All @@ -32,27 +23,4 @@ async function run() {
}
}

function parseBoolean(s: string): boolean {
switch (s) {
case 'y':
case 'Y':
case 'yes':
case 'Yes':
case 'YES':
case 'true':
case 'True':
case 'TRUE':
return true;
case 'n':
case 'N':
case 'no':
case 'No':
case 'NO':
case 'false':
case 'False':
case 'FALSE':
return false;
}
throw `invalid boolean value: ${s}`;
}
run();

0 comments on commit 83d4ed0

Please sign in to comment.