Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont Regex JSON files. Parse them instead #119

Open
eddiemonge opened this issue Jan 28, 2015 · 2 comments
Open

Dont Regex JSON files. Parse them instead #119

eddiemonge opened this issue Jan 28, 2015 · 2 comments

Comments

@eddiemonge
Copy link
Collaborator

Instead of the regex to read the JSON file, it should be read in, modified then written back out:

var jsonPath = 'path/to/file.json';
var json = require(jsonPath);
json = JSON.parse(json);
json.version = newVersion;
require('fs').write(jsonPath, json)

code is not to scale and is example only

@steveoh
Copy link

steveoh commented Jan 29, 2015

that assumes you're only going to bump versions in json files? That is not my use case.

@eddiemonge
Copy link
Collaborator Author

Well if the file isn't a .json then it can do a regular regex. If it is a JSON file then it should parse it and not regex it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants