The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Splitting CLI's stringify-package into its own module
I’m a contributor to the Apache Cordova project, which uses npm for handling the installation of output platforms and plugins. As part of this, we store some additional project-specific configuration information in package.json under a
One frequent complaint is that whenever Cordova makes changes to package.json, things like indents and newlines can end up getting reformatted due to
JSON.stringify behaviour. Ideally we want to match the behaviour of the npm CLI.
I spent some time yesterday digging into how npm formats the package.json after updating it, and conveniently there’s a util for stringifying and formatting the package: stringify-package
Unfortunately, it’s internal to the CLI, so I need to duplicate it if I want to have the same behaviour, and then it runs the risk of getting out of sync with npm’s version. I’d like to propose splitting stringify-package out into its own module so that it could be used by other projects without the risk of implementations getting out of sync.
I’m happy to do the work of making a new repo (preserving commit history for that file) and setting it up, but I feel like it probably makes sense for the npm team to own the repo and package. Is there interest in me setting up a repo for this, to be transferred to the npm team when everyone’s happy with it?
This sounds great! The repo is set up, and I’ve granted you collaborator privs. You should be able to push to it at your leisure.
I recommend using
$ npm init @iarna/npm to scaffold project files before you move things out. I’ve also done the juggling to get
latest to be the default branch, since we don’t use
master branches in our projects anymore.
Thanks so much for doing this!