Skip to content

Commit

Permalink
Merge pull request #3 from haya14busa/empty
Browse files Browse the repository at this point in the history
Allow empty for if_true and if_false input
  • Loading branch information
haya14busa authored Jan 20, 2020
2 parents 0d06892 + 99bd012 commit 9d07d2f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ inputs:
required: true
if_true:
description: 'output value if cond is true'
required: true
if_false:
description: 'output value if cond is false'
required: true
outputs:
value:
description: 'output value'
Expand Down
11 changes: 11 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ test('test runs (false)', () => {
}
console.log(cp.execSync(`node ${ip}`, options).toString())
})

test('test runs (empty)', () => {
process.env['INPUT_COND'] = 'true'
process.env['INPUT_IF_TRUE'] = ''
process.env['INPUT_IF_FALSE'] = 'value-if-false'
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecSyncOptions = {
env: process.env
}
console.log(cp.execSync(`node ${ip}`, options).toString())
})
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: 'Conditional value for GitHub Action'
description: 'Conditional value for GitHub Action - missing expression for GitHub Actions'
name: 'Conditional value - missing expression for GitHub Actions'
description: 'Conditional value - missing expression for GitHub Actions'
author: 'haya14busa'
inputs:
cond:
description: 'condition. [true,false]'
required: true
if_true:
description: 'output value if cond is true'
required: true
default: ''
if_false:
description: 'output value if cond is false'
required: true
default: ''
outputs:
value:
description: 'output value'
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const cond = core.getInput('cond', { required: true });
const ifTrue = core.getInput('if_true', { required: true });
const ifFalse = core.getInput('if_false', { required: true });
const ifTrue = core.getInput('if_true');
const ifFalse = core.getInput('if_false');
core.setOutput('value', cond === 'true' ? ifTrue : ifFalse);
}
catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import * as core from '@actions/core'
async function run(): Promise<void> {
try {
const cond: string = core.getInput('cond', {required: true})
const ifTrue: string = core.getInput('if_true', {required: true})
const ifFalse: string = core.getInput('if_false', {required: true})
const ifTrue: string = core.getInput('if_true')
const ifFalse: string = core.getInput('if_false')
core.setOutput('value', cond === 'true' ? ifTrue : ifFalse)
} catch (error) {
core.setFailed(error.message)
Expand Down

0 comments on commit 9d07d2f

Please sign in to comment.