Adds option to trim output (#9)
This commit is contained in:
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -13,4 +13,5 @@ jobs:
|
||||
- uses: ./
|
||||
id: package
|
||||
with:
|
||||
path: package.json
|
||||
path: package.json
|
||||
trim: true
|
||||
|
||||
@@ -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 }}
|
||||
```
|
||||
|
||||
@@ -8,6 +8,9 @@ inputs:
|
||||
path:
|
||||
description: 'File path'
|
||||
required: true
|
||||
trim:
|
||||
description: 'Trims output'
|
||||
required: false
|
||||
outputs:
|
||||
content:
|
||||
description: 'File content'
|
||||
|
||||
7
index.js
7
index.js
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
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