Adds option to trim output (#9)

This commit is contained in:
Min Huang
2021-05-26 02:47:18 -07:00
committed by GitHub
parent 74dc4b4435
commit 38dbfa4e4a
5 changed files with 6970 additions and 3 deletions

View File

@@ -13,4 +13,5 @@ jobs:
- uses: ./
id: package
with:
path: package.json
path: package.json
trim: true

View File

@@ -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 }}
```

View File

@@ -8,6 +8,9 @@ inputs:
path:
description: 'File path'
required: true
trim:
description: 'Trims output'
required: false
outputs:
content:
description: 'File content'

View File

@@ -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

File diff suppressed because it is too large Load Diff