Accept json or string encoding of result

This commit is contained in:
Jonathan Clem
2020-01-08 14:39:09 -05:00
parent 1a49f59545
commit 622ce3121a
3 changed files with 41 additions and 4 deletions

View File

@@ -18,7 +18,24 @@ async function main() {
const script = core.getInput('script', {required: true})
const fn = new AsyncFunction('require', 'github', 'context', script)
const result = await fn(require, client, context)
core.setOutput('result', JSON.stringify(result))
let encoding = core.getInput('result-enoding')
encoding = encoding != null ? encoding : 'json'
let output
switch (encoding) {
case 'json':
result = JSON.stringify(result)
break
case 'string':
result = String(result)
break
default:
throw new Error('"result-encoding" must be either "string" or "json"')
}
core.setOutput('result', result)
}
function handleError(err) {