Skip to content

Commit

Permalink
Use new core library, do not trim whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
frabert committed Jun 27, 2021
1 parent 110e444 commit 9b62dfe
Show file tree
Hide file tree
Showing 28 changed files with 489 additions and 153 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
replace-with: '$1'
- name: Check equality
run: '[[ "${{ steps.test.outputs.replaced }}" == "1.0.1" ]]'
test-json:
test-whitespace:
runs-on: ubuntu-latest
name: Test
name: Test whitespaces
steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -28,8 +28,7 @@ jobs:
with:
string: '_replace_underscores_'
pattern: '_'
replace-with: '" "'
replace-with: ' '
flags: 'g'
json: true
- name: Check equality
run: '[[ "${{ steps.test.outputs.replaced }}" == " replace underscores " ]]'
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ Replaces strings with regular expressions.

Flags to use when matching. Please refer to [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) for more information.

### `json`

Boolean. Interprets `replace-with` as JSON data. Useful for when `replace-with` contains leading or trailing whitespace that would be trimmed away by GitHub.

## Outputs

### `replaced`
Expand All @@ -33,7 +29,7 @@ The replaced string.
## Example usage

```yaml
uses: frabert/replace-string-action@v1.2
uses: frabert/replace-string-action@v2.0
with:
pattern: 'Hello, (\w+)!'
string: 'Hello, world!'
Expand Down
3 changes: 0 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ inputs:
flags:
description: 'Flags to use when matching'
required: false
json:
description: 'Interprets `replace-with` as JSON data. Useful for when `replace-with` contains leading or trailing whitespace that would be trimmed away by GitHub'
required: false
outputs:
replaced:
description: 'The output string'
Expand Down
7 changes: 1 addition & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ const core = require('@actions/core');
try {
const pattern = core.getInput('pattern');
const string = core.getInput('string');
let replaceWith = core.getInput('replace-with');
const replaceWith = core.getInput('replace-with', { trimWhitespace: false });
const flags = core.getInput('flags');
const json = core.getInput('json');

if(json) {
replaceWith = JSON.parse(replaceWith);
}

const regex = new RegExp(pattern, flags);

Expand Down
9 changes: 9 additions & 0 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 76 additions & 7 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 43 additions & 17 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b62dfe

Please sign in to comment.