Adds option to trim output (#9)
This commit is contained in:
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@@ -14,3 +14,4 @@ jobs:
|
|||||||
id: package
|
id: package
|
||||||
with:
|
with:
|
||||||
path: package.json
|
path: package.json
|
||||||
|
trim: true
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ steps:
|
|||||||
uses: juliangruber/read-file-action@v1
|
uses: juliangruber/read-file-action@v1
|
||||||
with:
|
with:
|
||||||
path: ./package.json
|
path: ./package.json
|
||||||
|
trim: false
|
||||||
- name: Echo package.json
|
- name: Echo package.json
|
||||||
run: echo ${{ steps.package.outputs.content }}
|
run: echo ${{ steps.package.outputs.content }}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ inputs:
|
|||||||
path:
|
path:
|
||||||
description: 'File path'
|
description: 'File path'
|
||||||
required: true
|
required: true
|
||||||
|
trim:
|
||||||
|
description: 'Trims output'
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
content:
|
content:
|
||||||
description: 'File content'
|
description: 'File content'
|
||||||
|
|||||||
7
index.js
7
index.js
@@ -5,7 +5,12 @@ const { promises: fs } = require('fs')
|
|||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const path = core.getInput('path')
|
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)
|
core.setOutput('content', content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6959
package-lock.json
generated
6959
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user