I am trying to replace the version number in a couple of files using the package.json file and "replace": "1.1.0" by running an npm script. I am running into a Regex issue I believe with the replace. I think maybe the solution should be some kind of regex grouping where I just replace the .*
value with just $npm_package_version
= solved, but I don't know how to do that.
Package.json version = "version": "2.0.45",
Strings to find = "ApiVersion": "Any number and periods like this 1.2.67",
Code Attempted = "updateVersion": "replace \"\"ApiVersion\": .*\",\" \"\"ApiVersion\": \"$npm_package_version\",\" ../appsettings.json",
Expected Outcome = in file appsetting.json the ApiVersion should be changed to = "ApiVersion": "2.0.45",
Error Received = "ApiVersion": "$npm_package_version",
I am assuming there is something going on here with regex, but I can't figure out how to get the npm package version var to render inside the string value. It works just as $npm_package_version
.