From 3002aead6b1019fd4e26c0cc3cd6abdcc7c3ddcd Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 17 Jun 2015 14:18:47 +0100 Subject: [PATCH] Add better install message on missing nodes --- red/nodes/deprecated.js | 15 ++++++++++++++- red/nodes/flows.js | 14 ++++++++++++-- red/nodes/index.js | 2 +- test/red/nodes/flows_spec.js | 4 ++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/red/nodes/deprecated.js b/red/nodes/deprecated.js index f570825f4..4d3eee585 100644 --- a/red/nodes/deprecated.js +++ b/red/nodes/deprecated.js @@ -26,7 +26,20 @@ var nodes = { "redis out": {module:"node-red-node-redis"}, "mongodb": {module:"node-red-node-mongodb"}, - "mongodb out": {module:"node-red-node-mongodb"} + "mongodb out": {module:"node-red-node-mongodb"}, + + "serial in": {module:"node-red-node-serialport"}, + "serial out": {module:"node-red-node-serialport"}, + "serial-port": {module:"node-red-node-serialport"}, + + "twitter-credentials": {module:"node-red-node-twitter"}, + "twitter in": {module:"node-red-node-twitter"}, + "twitter out": {module:"node-red-node-twitter"}, + + "e-mail": {module:"node-red-node-email"}, + "e-mail in": {module:"node-red-node-email"}, + + "feedparse": {module:"node-red-node-feedparser"} } module.exports = { diff --git a/red/nodes/flows.js b/red/nodes/flows.js index 6e10589ec..254809c58 100644 --- a/red/nodes/flows.js +++ b/red/nodes/flows.js @@ -24,6 +24,7 @@ var log = require("../log"); var events = require("../events"); var redUtil = require("../util"); var storage = null; +var settings = null; var deprecated = require("./deprecated"); var activeFlow = null; @@ -40,7 +41,8 @@ events.on('type-registered',function(type) { }); var flowNodes = module.exports = { - init: function(_storage) { + init: function(_settings, _storage) { + settings = _settings; storage = _storage; }, @@ -148,12 +150,20 @@ var flowNodes = module.exports = { for (var i=0;i 0) { + log.info("To install any of these missing modules, run:"); + log.info(" npm install "); + log.info("in the directory:"); + log.info(" "+settings.userDir); + } } } }, diff --git a/red/nodes/index.js b/red/nodes/index.js index 1e7d19d23..d1c84b8a1 100644 --- a/red/nodes/index.js +++ b/red/nodes/index.js @@ -54,7 +54,7 @@ function createNode(node,def) { function init(_settings,storage,app) { credentials.init(storage,app); - flows.init(storage); + flows.init(_settings,storage); registry.init(_settings); } diff --git a/test/red/nodes/flows_spec.js b/test/red/nodes/flows_spec.js index b74f36773..b986f92f1 100644 --- a/test/red/nodes/flows_spec.js +++ b/test/red/nodes/flows_spec.js @@ -166,7 +166,7 @@ describe('flows', function() { var testFlow = [{"type":"testNode","credentials":{"a":1}},{"type":"testNode2"}]; var resultFlow = clone(testFlow); var storage = { saveFlows: sinon.spy() }; - flows.init(storage); + flows.init({},storage); flows.setFlows(testFlow,"full").then(function() { try { credentialsExtact.calledOnce.should.be.true; @@ -194,7 +194,7 @@ describe('flows', function() { var testFlow = [{"type":"testNode"},{"type":"testNode2"}]; var testFlow2 = [{"type":"testNode3"},{"type":"testNode4"}]; var storage = { saveFlows: sinon.spy() }; - flows.init(storage); + flows.init({},storage); flows.setFlows(testFlow,"full").then(function() { flows.setFlows(testFlow2,"nodes").then(function() {