Skip to content

Commit 9b62dfe

Browse files
committed
Use new core library, do not trim whitespace
1 parent 110e444 commit 9b62dfe

28 files changed

Lines changed: 489 additions & 153 deletions

.github/workflows/test.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
replace-with: '$1'
1717
- name: Check equality
1818
run: '[[ "${{ steps.test.outputs.replaced }}" == "1.0.1" ]]'
19-
test-json:
19+
test-whitespace:
2020
runs-on: ubuntu-latest
21-
name: Test
21+
name: Test whitespaces
2222
steps:
2323
- name: Checkout
2424
uses: actions/checkout@v1
@@ -28,8 +28,7 @@ jobs:
2828
with:
2929
string: '_replace_underscores_'
3030
pattern: '_'
31-
replace-with: '" "'
31+
replace-with: ' '
3232
flags: 'g'
33-
json: true
3433
- name: Check equality
3534
run: '[[ "${{ steps.test.outputs.replaced }}" == " replace underscores " ]]'

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ Replaces strings with regular expressions.
2020

2121
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.
2222

23-
### `json`
24-
25-
Boolean. Interprets `replace-with` as JSON data. Useful for when `replace-with` contains leading or trailing whitespace that would be trimmed away by GitHub.
26-
2723
## Outputs
2824

2925
### `replaced`
@@ -33,7 +29,7 @@ The replaced string.
3329
## Example usage
3430

3531
```yaml
36-
uses: frabert/replace-string-action@v1.2
32+
uses: frabert/replace-string-action@v2.0
3733
with:
3834
pattern: 'Hello, (\w+)!'
3935
string: 'Hello, world!'

action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ inputs:
1414
flags:
1515
description: 'Flags to use when matching'
1616
required: false
17-
json:
18-
description: 'Interprets `replace-with` as JSON data. Useful for when `replace-with` contains leading or trailing whitespace that would be trimmed away by GitHub'
19-
required: false
2017
outputs:
2118
replaced:
2219
description: 'The output string'

index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ const core = require('@actions/core');
33
try {
44
const pattern = core.getInput('pattern');
55
const string = core.getInput('string');
6-
let replaceWith = core.getInput('replace-with');
6+
const replaceWith = core.getInput('replace-with', { trimWhitespace: false });
77
const flags = core.getInput('flags');
8-
const json = core.getInput('json');
9-
10-
if(json) {
11-
replaceWith = JSON.parse(replaceWith);
12-
}
138

149
const regex = new RegExp(pattern, flags);
1510

node_modules/@actions/core/LICENSE.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/README.md

Lines changed: 76 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.d.ts

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js

Lines changed: 43 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)