package.json scripts that work with npm and yarn?

前端 未结 2 1982
天涯浪人
天涯浪人 2021-02-13 18:38

I am using npm as a build tool and so in my package.json, and some of my scripts depend on other scripts:

{
  \"test\": \"npm run lint && mo         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-02-13 19:37

    While mjs' answer is great, there's also a small package that is purported to work on all environments including Windows: https://www.npmjs.com/package/yarpm

    To use in a project, run yarn add yarpm --dev / npm i -D yarpm and then just use yarpm in your scripts like this:

    {
      "test": "yarpm run lint && mocha"
    }
    

    As the package README notes, you just need to make sure your commands would be suitable for passing through to either yarn or npm: you cannot use arguments/flags that only work on one package manager.

提交回复
热议问题