mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Fully remove when.js dependency
This commit is contained in:
@@ -14,8 +14,6 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var when = require('when');
|
||||
|
||||
var externalAPI = require("./api");
|
||||
|
||||
var redNodes = require("./nodes");
|
||||
@@ -197,25 +195,24 @@ function start() {
|
||||
});
|
||||
}
|
||||
|
||||
var reinstallAttempts;
|
||||
var reinstallAttempts = 0;
|
||||
var reinstallTimeout;
|
||||
function reinstallModules(moduleList) {
|
||||
var promises = [];
|
||||
var failedModules = [];
|
||||
var reinstallList = [];
|
||||
|
||||
for (var i=0;i<moduleList.length;i++) {
|
||||
if (settings.autoInstallModules && i != "node-red") {
|
||||
promises.push(redNodes.installModule(moduleList[i].id,moduleList[i].version));
|
||||
if (settings.autoInstallModules && moduleList[i].id != "node-red") {
|
||||
(function(mod) {
|
||||
promises.push(redNodes.installModule(mod.id,mod.version).then(m => {
|
||||
events.emit("runtime-event",{id:"node/added",retain:false,payload:m.nodes});
|
||||
}).catch(err => {
|
||||
reinstallList.push(mod);
|
||||
}));
|
||||
})(moduleList[i])
|
||||
}
|
||||
}
|
||||
when.settle(promises).then(function(results) {
|
||||
var reinstallList = [];
|
||||
for (var i=0;i<results.length;i++) {
|
||||
if (results[i].state === 'rejected') {
|
||||
reinstallList.push(moduleList[i]);
|
||||
} else {
|
||||
events.emit("runtime-event",{id:"node/added",retain:false,payload:results[i].value.nodes});
|
||||
}
|
||||
}
|
||||
Promise.all(promises).then(function(results) {
|
||||
if (reinstallList.length > 0) {
|
||||
reinstallAttempts++;
|
||||
// First 5 at 1x timeout, next 5 at 2x, next 5 at 4x, then 8x
|
||||
|
Reference in New Issue
Block a user