NodeJS生成的进程在Mac上运行,在Windows

时间:2016-07-28 18:31:40

标签: node.js windows macos vagrant

我从节点生成一个进程,在VM上运行vagrant ssh命令。这适用于Mac,但在Windows上失败并出现以下错误:

  

grep:没有这样的文件或目录

代码:

'use strict'
const spawn = require('cross-spawn')
const vagrantOptions = { cwd: `${__dirname}/../../vagrant/`, stdio: 'inherit' }
// this line works
spawn.sync('vagrant', ['ssh', 'xms-dev', '-c', 'sudo service supervisor stop'], vagrantOptions))

// this line doesn't work on Windows
spawn.sync('vagrant', ['ssh', 'xms-dev', '-c', 'sudo service supervisor status | grep -q "not running"; until [ $? -eq 0 ]; do sleep 1; sudo service supervisor status | grep -q "not running"; done'], vagrantOptions))

如果我自己在Windows上运行该过程,它会按预期工作。

0 个答案:

没有答案