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

package.json formatting #72

Closed
fvanwijk opened this issue Nov 12, 2015 · 4 comments
Closed

package.json formatting #72

fvanwijk opened this issue Nov 12, 2015 · 4 comments

Comments

@fvanwijk
Copy link

When I run commitizen init cz-conventional-changelog --save --save-exact the cz-conventional-changelog is added to package.json as promised, but my package.json is modified in such a way that all whitespace is gone. So there is only a very long line.

I'm not sure if this also happens with other commands.

@jimthedev
Copy link
Member

Hmmm probably because we use JSON.parse. I'll have to look into other ways
to do this like a regex or something. Can you show me an example of a your
package.json with new lines just to make sure I'm understanding correctly.
Thanks!
On Thu, Nov 12, 2015 at 7:26 AM Frank van Wijk [email protected]
wrote:

When I run commitizen init cz-conventional-changelog --save --save-exact
the cz-conventional-changelog is added to package.json as promised, but
my package.json is modified in such a way that all newlines etc are gone.
So there is only a very long line.

I'm not sure if this also happens with other commands.


Reply to this email directly or view it on GitHub
#72.

@fvanwijk
Copy link
Author

You can reproduce it yourself easily. Do npm init -y in an empty folder and call commitizen init cz-conventional-changelog --save --save-exact.

Package.json contents:

{"name":"test123","version":"1.0.0","description":"","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"MIT","devDependencies":{"cz-conventional-changelog":"1.1.4"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}}}

@jimthedev
Copy link
Member

@fvanwijk I see what you're saying.

In the next release I will fix this and make sure to use this package to detect the indentation preferences.

@fvanwijk
Copy link
Author

Nice! It would be nice when the result is the same as when you're doing npm install ... --save, which also allows for adding stuff to package.json but obeys current formatting.

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

No branches or pull requests

2 participants