如果我执行shell.exec('http'),就会得到httpie的帮助,它是我使用的请求库。但是,如果我添加一个参数(如下面所示),shelljs将不会调用回调。
var shell = require('shelljs');
shell.exec('http http://www.example.com/', {async: true, silent: false}, function(data){
console.log(data);
})如果我使用curl而不是http,上面的示例确实有效。知道为什么它不和http一起工作吗?
发布于 2015-08-24 10:06:29
添加ignore-stdin选项
var shell = require('shelljs');
shell.exec('http --ignore-stdin http://www.example.com/', {async: true, silent: false}, function(data){
console.log(data);
});--ignore-stdin选项阻止HTTPie从stdin读取数据,而在非交互调用期间,这通常不可取。
您可以在海蒂派的脚本部分阅读更多内容。
https://stackoverflow.com/questions/31994967
复制相似问题