Edit package.json from command line

前端 未结 5 435
北恋
北恋 2021-01-30 01:19

I\'m trying to add or edit a variable in my package.json from a shell script. So if i have a package.json like this:

{
  \"name\": \"my-project\",
  \"descripti         


        
5条回答
  •  感情败类
    2021-01-30 02:26

    If you don't want to install anything, you can also use a one-line script to modify the package.json:

    node -e "let pkg=require('./package.json'); pkg.homepage='${CI_PAGES_URL}'; require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
    

提交回复
热议问题