Skip to content

Commit

Permalink
Adds option to trim output (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
retiman authored May 26, 2021
1 parent 74dc4b4 commit 38dbfa4
Show file tree
Hide file tree
Showing 5 changed files with 6,970 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ jobs:
- uses: ./
id: package
with:
path: package.json
path: package.json
trim: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ steps:
uses: juliangruber/read-file-action@v1
with:
path: ./package.json
trim: false
- name: Echo package.json
run: echo ${{ steps.package.outputs.content }}
```
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
path:
description: 'File path'
required: true
trim:
description: 'Trims output'
required: false
outputs:
content:
description: 'File content'
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ const { promises: fs } = require('fs')

const main = async () => {
const path = core.getInput('path')
const content = await fs.readFile(path, 'utf8')
const trim = core.getBooleanInput('trim')
let content = await fs.readFile(path, 'utf8')
if (trim) {
content = content.trim
}

core.setOutput('content', content)
}

Expand Down
Loading

0 comments on commit 38dbfa4

Please sign in to comment.