diff --git a/README.md b/README.md index 53c38fd..5ed1d11 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # replace-action -This lightweight action replaces substrings in files. It is useful for CI process when you needto update your configs depending on the previous steps results. +This lightweight action replaces substrings in files. It is useful for CI process when you need to update your configs depending on the previous steps results. # Usage @@ -11,8 +11,9 @@ See [action.yml](action.yml) uses: datamonsters/replace-action with: files: 'path1/file1,path2/file2' - replacements: 'foo=bar,$FOO=Bar_Value' + replacements: 'foo=bar,@FOO=Bar_Value' ``` +As the replacement is using regular expression, you should avoid 'special' characters which might be misinterpreted in the RegEx context. # Example @@ -73,4 +74,4 @@ jobs: # License -The scripts and documentation in this project are released under the [MIT License](LICENSE) \ No newline at end of file +The scripts and documentation in this project are released under the [MIT License](LICENSE) diff --git a/index.js b/index.js index 493e581..bbfb427 100755 --- a/index.js +++ b/index.js @@ -22,7 +22,8 @@ try { var kv = vars[i].split('=') var key = kv[0] var value = kv[1] - result = result.replace(key, value) + var regx = new RegExp(key, 'g') + result = result.replace(regx, value) } console.log('file2: '+filename) fs.writeFile(filename, result, 'utf8', function (err) {