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

Allow node modules to declare supported versions of node-red

This commit is contained in:
Nick O'Leary 2015-07-10 21:42:14 +01:00
parent 999cf66b27
commit 846ab08661
4 changed files with 43 additions and 30 deletions

View File

@ -50,6 +50,7 @@
"passport-oauth2-client-password":"0.1.2",
"oauth2orize":"1.0.1",
"i18next":"1.7.10",
"semver": "4.3.6",
"node-red-node-feedparser":"0.0.*",
"node-red-node-email":"0.0.*",
"node-red-node-twitter":"0.0.*"

View File

@ -17,6 +17,7 @@
var when = require("when");
var fs = require("fs");
var path = require("path");
var semver = require("semver");
var events = require("../../events");
@ -55,6 +56,11 @@ function loadNodeFiles(nodeFiles) {
for (var module in nodeFiles) {
/* istanbul ignore else */
if (nodeFiles.hasOwnProperty(module)) {
if (nodeFiles[module].redVersion &&
!semver.satisfies(RED.version().replace("-git",""), nodeFiles[module].redVersion)) {
//TODO: log it
continue;
}
if (module == "node-red" || !registry.getModuleInfo(module)) {
var first = true;
for (var node in nodeFiles[module].nodes) {

View File

@ -238,6 +238,9 @@ function getNodeFiles(_defaultNodesDir,disableNodePathScan) {
version: moduleFile.package.version,
nodes: {}
};
if (moduleFile.package['node-red'].version) {
nodeList[moduleFile.package.name].redVersion = moduleFile.package['node-red'].version;
}
nodeModuleFiles.forEach(function(node) {
nodeList[moduleFile.package.name].nodes[node.name] = node;
});
@ -264,6 +267,9 @@ function getModuleFiles(module) {
version: moduleFile.package.version,
nodes: {}
};
if (moduleFile.package['node-red'].version) {
nodeList[moduleFile.package.name].redVersion = moduleFile.package['node-red'].version;
}
nodeModuleFiles.forEach(function(node) {
nodeList[moduleFile.package.name].nodes[node.name] = node;
});

View File

@ -67,7 +67,7 @@ var RED = {
var p = require(path.join(process.env.NODE_RED_HOME,"package.json")).version;
/* istanbul ignore else */
if (fs.existsSync(path.join(process.env.NODE_RED_HOME,".git"))) {
p += ".git";
p += "-git";
}
return p;
},