Skip to content

Commit

Permalink
log option
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoG60 committed Dec 8, 2020
1 parent 17b147f commit 6f92884
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ with:
hard-fail: false # - When set to true, the workflow fails if it
# can't find a corresponding variable in the env
# Optional. Default: false
enable-log: false # - Whether to log the content of the files
```
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
hard-fail:
description: 'Indicate whether to make the action fail when a match could not be replaced. Default just prints a warning'
default: false
enable-log:
description: 'Whether the action should log the input and output content'
default: false
runs:
using: 'node12'
main: 'dist/index.js'
13 changes: 9 additions & 4 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ async function run() {
const input = core.getInput('input', {required: true})
const output = core.getInput('output')
const hard_fail = core.getInput('hard-fail') !== 'false'
const log = core.getInput('enable-log') !== 'false'

if(output)
await fs.mkdir(output, {recursive: true})
Expand All @@ -30,13 +31,17 @@ async function run() {

const data = await handle.readFile('utf8')

console.log(`===== ORIGINAL: ${file} ======`)
console.log(data)



const rendered = renderer.render(data, /\$\{([A-Z_-]+)\}/gm, hard_fail)

console.log("===== PROCESSED ======")
console.log(rendered)
if(log) {
console.log(`===== ORIGINAL: ${file} ======`)
console.log(data)
console.log("===== PROCESSED ======")
console.log(rendered)
}

if(output) {
await handle.close();
Expand Down

0 comments on commit 6f92884

Please sign in to comment.