且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

npm install如果package.json被修改

更新时间:2021-11-26 09:54:49

好的,这样我就完成了.在这里.您可以完全按照您在理想情况下指定的方式使用它.只需 npm install install-changed 并将其添加到自定义脚本中,例如您的示例中的 pre-run .它应该确定是否需要 npm install ,并在需要时执行此操作.

Okay so I'm done with the package. Here it is. You can use it exactly the same way you specified in your ideal scenario. Just npm install install-changed and add it to a custom script, like pre-run in your example. It should figure out whether or not it needs to npm install and does so if it needs to.

 {
  "scripts": {
    "pre-run": "install-changed",
    "my-script": "…"
  },

您也可以通过编程方式执行此操作,但我认为您不需要此功能.

You can also do this programatically but I don't think you're going to need this.

let installChanged = require('install-changed')

let isModified = installChanged.watchPackage() 

上面的函数做的事情完全相同,此外,它还返回一个布尔值,您可能会发现它有用.

The function above does exactly the same thing, additonally it also returns a boolean value which you might find useful.