Skip to content

Commit

Permalink
trilom#81: Allow single spaces in format
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Orner committed Mar 23, 2020
1 parent 8f64910 commit 77d17fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ _Optional_ - `string` - specific github token, github.token is used by default

### output

_Optional_ - `string` - type of output for output variables, default is json. Use ',' for comma separated values, or ' ' for space delimited values. You can also create your own delimiter for example ' |FILE:' will output 'file1.yml |FILE:file2.yml |FILE:file3.yml'.
_Optional_ - `string` - type of output for output variables, default is json. Use ',' for comma separated values, or 'space' for space delimited values. You can also create your own delimiter for example ' |FILE:' will output 'file1.yml |FILE:file2.yml |FILE:file3.yml'.

### fileOutput

_Optional_ - `string` - type of output for file output, default is json. Use ',' for comma separated values, or ' ' for space delimited values. You can also create your own delimiter for example `\ |FILE:` will output:
_Optional_ - `string` - type of output for file output, default is json. Use ',' for comma separated values, or 'space' for space delimited values. You can also create your own delimiter for example `\ |FILE:` will output:

> file1.yml |FILE:file2.yml |FILE:file3.yml
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
cat $HOME/files.csv
```

You can set the output and fileOutput to ' ' for txt output. We also used a specific token, and got info for the PR that this push came from.
You can set the output and fileOutput to 'space' for txt output. We also used a specific token, and got info for the PR that this push came from.

```yaml
name: push-develop
Expand All @@ -190,9 +190,9 @@ jobs:
with:
githubToken: ${{ env.BOT_USER_TOKEN }}
prNumber: ${{ steps.pr.outputs.results }}
output: ' '
fileOutput: ' '
output: space
fileOutput: space
- name: test
run: |
cat $HOME/files.txt
```
```
3 changes: 3 additions & 0 deletions src/FilesHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export function formatChangedFiles(format: string, files: string[]): string {
if (format === 'json') {
return JSON.stringify(files)
}
else if (format === 'space') {
return files.join(' ');
}
return files.join(format)
}

Expand Down
1 change: 1 addition & 0 deletions src/tests/FilesHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ describe('Testing FilesHelper.ts...', () => {
const ext = require('../FilesHelper').formatChangedFiles(format, input)
expect(ext).toBe(expected)
if (format === 'json') expect(ext).toBe(`["${input[0]}","${input[1]}"]`)
else if (format === 'space') expect(ext).toBe(`${input[0]} ${input[1]}`)
else expect(ext).toBe(`${input[0]}${format}${input[1]}`)
})
it.each(getTestEvents(p.changedFilesInput('push'), 'push'))(
Expand Down

0 comments on commit 77d17fc

Please sign in to comment.