【发布时间】:2019-10-16 14:08:28
【问题描述】:
我有一个带有类的 nodejs 模块。
类里面有一个调用newman(Postman cli runner)的方法
无法弄清楚如何返回 newman 运行结果数据。 newman 调用本身(在模块之外)可以正常工作。
我的模块.js
var newman = require('newman');
module.exports = function (collection, data) {
this.run = function () {
newman.run({
collection: require(this.collection + '.postman_collection.json'),
environment: require(this.environment + '.postman_environment.json')
}, function () {
console.log('in callback');
}).on('start', function (err, args) {
}).on('beforeDone', function (err, data) {
}).on('done', function (err, summary) {
});
return 'some result';
}
}
index.js
var runNewman = require('./mymodule');
var rn = new runNewman(cName, cData);
var result = rn.run(); // never returns any variable
cosole.log(result);
【问题讨论】:
标签: node.js node-modules newman