1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'master' into runtime-api

This commit is contained in:
Nick O'Leary 2018-07-30 10:13:51 +01:00
commit 06abe63fb1
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -38,6 +38,8 @@ function init(runtime) {
log = runtime.log; log = runtime.log;
} }
var activePromise = Promise.resolve();
function checkModulePath(folder) { function checkModulePath(folder) {
var moduleName; var moduleName;
var err; var err;
@ -73,8 +75,9 @@ function checkExistingModule(module,version) {
return false; return false;
} }
function installModule(module,version) { function installModule(module,version) {
activePromise = activePromise.then(() => {
//TODO: ensure module is 'safe' //TODO: ensure module is 'safe'
return new Promise(function(resolve,reject) { return new Promise((resolve,reject) => {
var installName = module; var installName = module;
var isUpgrade = false; var isUpgrade = false;
try { try {
@ -146,6 +149,12 @@ function installModule(module,version) {
} }
}); });
}); });
}).catch(err => {
// In case of error, reset activePromise to be resolvable
activePromise = Promise.resolve();
throw err;
});
return activePromise;
} }
@ -178,7 +187,8 @@ function reportRemovedModules(removedNodes) {
} }
function uninstallModule(module) { function uninstallModule(module) {
return new Promise(function(resolve,reject) { activePromise = activePromise.then(() => {
return new Promise((resolve,reject) => {
if (/[\s;]/.test(module)) { if (/[\s;]/.test(module)) {
reject(new Error(log._("server.install.invalid"))); reject(new Error(log._("server.install.invalid")));
return; return;
@ -218,6 +228,12 @@ function uninstallModule(module) {
} }
); );
}); });
}).catch(err => {
// In case of error, reset activePromise to be resolvable
activePromise = Promise.resolve();
throw err;
});
return activePromise;
} }
function checkPrereq() { function checkPrereq() {
@ -230,7 +246,7 @@ function checkPrereq() {
paletteEditorEnabled = false; paletteEditorEnabled = false;
return Promise.resolve(); return Promise.resolve();
} else { } else {
return new Promise(function(resolve) { return new Promise(resolve => {
child_process.execFile(npmCommand,['-v'],function(err) { child_process.execFile(npmCommand,['-v'],function(err) {
if (err) { if (err) {
log.info(log._("server.palette-editor.npm-not-found")); log.info(log._("server.palette-editor.npm-not-found"));