mkdir(dirPath).then(function () { return when.promise(function (res, rej) { var read = fs.createReadStream(packagePath); var write = fs.createWriteStream(path.join(dirPath, 'package.json')); read.pipe(write); read.on('error', rej); write.on('error', rej); write.on('close', res); }); })
.then(getConfigWithPaths) .then(getConfigWithGraph) .then(handleOptionalDependencies) .then(ensureBundleExists) .then(getConfigWithNpmCacheContents) .then(getConfigWithBundleContents) .then(getConfigWithDependencies) .then(getConfigWithUnusedDependencies) .then(getConfigWithStats); .then(function (npmCache) { return assign(config, {npmCache: npmCache}); }); .then(function (deps) { return assign(config, {deps: deps}); }); .then(function (unusedDependencies) { return assign(config, {unusedDependencies: unusedDependencies}); }); .then(function (stats) { return assign(config, {stats: stats}); });
}); nmWhen.settle(promises).done(function(descriptors) { var success = true; nm_.each(descriptors, function(descriptor, index) {
//连接本地消息队列服务 amqp.connect('amqp://127.0.0.1:5672').then(function(conn){ //创建通道,让when立即执行promise return when(conn.createChannel().then(function(ch){ var q = 'hello'; var msg = 'Hello World'; //监听q队列,设置持久化为false。 return ch.assertQueue(q,{durable: false}).then(function(_qok){ //监听成功后向队列发送消息,这里我们就简单发送一个字符串。发送完毕后关闭通道。 ch.sendToQueue(q,new Buffer(msg)); console.log(" [x] Sent '%s'",msg); return ch.close() }); })).ensure(function(){ //ensure是promise.finally的别名,不管promise的状态如何都会执行的函数 //这里我们把连接关闭 conn.close(); }); }).then(null,console.warn);
return remove(container, entry) }) .then(function () {
}) }, 0).then(() => { console.log('all done'); console.timeEnd("timetaken");
promises = promises.concat(fixMissing.call(self, missing)); nmWhen.settle(promises).done(function(descriptors) { var success = true; nm_.each(descriptors, function(descriptor, index) {
promises = promises.concat(fixMissing.call(self, missing)); nmWhen.settle(promises).done(function(descriptors) { var success = true; nm_.each(descriptors, function(descriptor, index) {
.then(bodyObj => Spark.webhookAuth(Spark.webhookSecret, sig, bodyObj)) .then(bodyObj => when(processBody(bodyObj))) .catch(err => debug(err)); } else if (xor(sig, Spark.webhookSecret)) { const secretSigErr = new Error('webhookListen ignored callback due to inconsistent webhook signature or secret'); } else { when(body) .then(bodyObj => when(processBody(bodyObj))) .catch(err => debug(err));
}) }, 0).then(() => { console.log('all done'); console.timeEnd("timetaken");