replace-in-file icon indicating copy to clipboard operation
replace-in-file copied to clipboard

Issue on Windows

Open TomSinclair opened this issue 1 year ago • 0 comments

Hello!

I'm running in to an issue when running a replace on Windows. I have tested on my local Mac and it works fine but on a Windows machine it causes an OS level error.

I am attempting to replace all mentions of a string "/assets/" in multiple places in each file with another string "/static/assets/". I am using the CLI to run the script from a package.json file after some HTML has been compiled.

The node script I am using is:

"path-replace": "replace-in-file --configFile=replace-in-file.js --dry"

On Mac the results are below:

Replacing '/\/assets\//g' with '/static2/assets/'
4 file(s) were changed

But on Windows I receive an OS error "Expected identifier, string or number" Line 5 Char 1

The config file I am using is below:

module.exports = {
  files: "../wwwroot/static/**",
  from: /\/assets\//g,
  to: "/static/assets/",
};

I thought it may be an OS issue with the trailing comma on line 4 but removing that results in a different error "'module' is undefined' Line 1 Char 1

Thank you for any assistance with this :)

TomSinclair avatar Dec 28 '23 15:12 TomSinclair