How to execute 'npm run' command programmatically?

前端 未结 3 1542
日久生厌
日久生厌 2021-02-05 02:08

I have some custom testing script, which I can run with npm run test command, which executes some Node script for starting e2e/unit tests. But before it I must star

3条回答
  •  轮回少年
    2021-02-05 02:43

    Use PM2, it is really usefull and easy...

    npm install pm2
    
    const pm2 = require('pm2');
    
    pm2.start({
        script: 'npm -- run monitorTheWeather',
        autorestart : false 
      }, (err, apps) => {
        pm2.disconnect()
        if (err) { throw err }
      })
    

提交回复
热议问题