I am using npm and yarn to manage dependencies for a project. As suggested in this question: How do I add comments to package.json for npm install? I'm using the following format to be able to include comments in the pacakge.json. Here's a sample:
"scripts": {
"////":"LIVE BROWSER RELOAD",
"serve:patternlab": "BUILD_TO='patternlab' browser-sync start --config browsersync.config.js",
"serve:site": "browser-sync start --config browsersync.config.js",
"////":"LINTING COMMANDS",
"lint:js": "eslint $npm_package_config_src_js --ignore-pattern **/vendor/**/*.js || true",
"lint:css": "sass-lint $npm_package_config_src_css**/*.scss -v -q || true",
"lint": "npm-run-all -p lint:js lint:css",
}
This format makes it easy to see what each set of scripts is doing. However, whenever I run yarn add
to add a new package, it strips out all the comments except the last one (which gets moved to the top of the scripts
object), and strips out the line breaks. Is there anything I can do to avoid this happening?
This was the closest I was able to get in to what I wanted to achieve. The following is preserved after running yarn add
and adds some separation to each set of scripts:
"scripts": {
"//LIVE BROWSER RELOAD": "--------------------------------------------------------------------------",
"serve:patternlab": "BUILD_TO='patternlab' browser-sync start --config browsersync.config.js",
"serve:site": "browser-sync start --config browsersync.config.js"
,
"//LINTING COMMANDS": "-----------------------------------------------------------------------------",
"lint:js": "eslint $npm_package_config_src_js --ignore-pattern **/vendor/**/*.js || true",
"lint:css": "sass-lint $npm_package_config_src_css/**/*.scss -v -q || true",
"lint": "npm-run-all -p lint:js lint:css"
}