mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Tidy up flow/util
This commit is contained in:
parent
f196493402
commit
3209777aba
@ -13,16 +13,22 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
var clone = require("clone");
|
const clone = require("clone");
|
||||||
var redUtil = require("@node-red/util").util;
|
const redUtil = require("@node-red/util").util;
|
||||||
var Log = require("@node-red/util").log;
|
const Log = require("@node-red/util").log;
|
||||||
var subflowInstanceRE = /^subflow:(.+)$/;
|
const typeRegistry = require("@node-red/registry");
|
||||||
var typeRegistry = require("@node-red/registry");
|
const subflowInstanceRE = /^subflow:(.+)$/;
|
||||||
const credentials = require("../nodes/credentials");
|
|
||||||
|
|
||||||
let _runtime = null;
|
let _runtime = null;
|
||||||
|
let envVarExcludes = {};
|
||||||
|
|
||||||
var envVarExcludes = {};
|
function init(runtime) {
|
||||||
|
_runtime = runtime;
|
||||||
|
envVarExcludes = {};
|
||||||
|
if (runtime.settings.hasOwnProperty('envVarExcludes') && Array.isArray(runtime.settings.envVarExcludes)) {
|
||||||
|
runtime.settings.envVarExcludes.forEach(v => envVarExcludes[v] = true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function diffNodes(oldNode,newNode) {
|
function diffNodes(oldNode,newNode) {
|
||||||
if (oldNode == null) {
|
if (oldNode == null) {
|
||||||
@ -121,6 +127,12 @@ async function evaluateEnvProperties(flow, env, credentials) {
|
|||||||
return evaluatedEnv
|
return evaluatedEnv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of a node
|
||||||
|
* @param {Flow} flow The containing flow
|
||||||
|
* @param {object} config The node configuration object
|
||||||
|
* @return {Node} The instance of the node
|
||||||
|
*/
|
||||||
async function createNode(flow,config) {
|
async function createNode(flow,config) {
|
||||||
var newNode = null;
|
var newNode = null;
|
||||||
var type = config.type;
|
var type = config.type;
|
||||||
@ -317,28 +329,13 @@ function parseConfig(config) {
|
|||||||
});
|
});
|
||||||
return flow;
|
return flow;
|
||||||
}
|
}
|
||||||
|
function getEnvVar(k) {
|
||||||
module.exports = {
|
|
||||||
init: function(runtime) {
|
|
||||||
_runtime = runtime;
|
|
||||||
envVarExcludes = {};
|
|
||||||
if (runtime.settings.hasOwnProperty('envVarExcludes') && Array.isArray(runtime.settings.envVarExcludes)) {
|
|
||||||
runtime.settings.envVarExcludes.forEach(v => envVarExcludes[v] = true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getEnvVar: function(k) {
|
|
||||||
if (!envVarExcludes[k]) {
|
if (!envVarExcludes[k]) {
|
||||||
return process.env[k];
|
return process.env[k];
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
}
|
||||||
|
function diffConfigs(oldConfig, newConfig) {
|
||||||
diffNodes,
|
|
||||||
mapEnvVarProperties,
|
|
||||||
evaluateEnvProperties,
|
|
||||||
parseConfig,
|
|
||||||
|
|
||||||
diffConfigs: function(oldConfig, newConfig) {
|
|
||||||
var id;
|
var id;
|
||||||
var node;
|
var node;
|
||||||
var nn;
|
var nn;
|
||||||
@ -621,14 +618,15 @@ module.exports = {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
return diff;
|
return diff;
|
||||||
},
|
}
|
||||||
|
|
||||||
/**
|
module.exports = {
|
||||||
* Create a new instance of a node
|
init,
|
||||||
* @param {Flow} flow The containing flow
|
createNode,
|
||||||
* @param {object} config The node configuration object
|
parseConfig,
|
||||||
* @return {Node} The instance of the node
|
diffConfigs,
|
||||||
*/
|
diffNodes,
|
||||||
createNode: createNode,
|
getEnvVar,
|
||||||
|
mapEnvVarProperties,
|
||||||
evaluateEnvProperties
|
evaluateEnvProperties
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user