mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Improve getModuleListForNodes
+ fix typo
This commit is contained in:
parent
5e9195ab99
commit
44b4c7da24
@ -3009,19 +3009,25 @@ RED.nodes = (function() {
|
||||
*/
|
||||
function getModuleListForNodes(nodes) {
|
||||
const modules = {}
|
||||
nodes.forEach(n => {
|
||||
const nodeSet = RED.nodes.registry.getNodeSetForType(n.type)
|
||||
if (nodeSet) {
|
||||
modules[nodeSet.module] = nodeSet.version
|
||||
const typeSet = new Set()
|
||||
nodes.forEach((n) => {
|
||||
if (!typeSet.has(n.type)) {
|
||||
typeSet.add(n.type)
|
||||
const nodeSet = RED.nodes.registry.getNodeSetForType(n.type)
|
||||
if (nodeSet) {
|
||||
modules[nodeSet.module] = nodeSet.version
|
||||
nodeSet.types.forEach((t) => typeSet.add(t))
|
||||
}
|
||||
}
|
||||
})
|
||||
return modules
|
||||
}
|
||||
|
||||
function updateGlobalConfigModuleList(nodes) {
|
||||
const modules = getModuleListForNodes(nodes)
|
||||
delete modules['node-red']
|
||||
const hasModules = (Object.keys(modules).length > 0)
|
||||
let globalConfigNode = nodes.find(n => n.type === 'global-config')
|
||||
let globalConfigNode = nodes.find((n) => n.type === 'global-config')
|
||||
if (!globalConfigNode && hasModules) {
|
||||
globalConfigNode = {
|
||||
id: RED.nodes.id(),
|
||||
@ -3030,7 +3036,7 @@ RED.nodes = (function() {
|
||||
modules
|
||||
}
|
||||
nodes.push(globalConfigNode)
|
||||
} else if (globalConfigNode) {
|
||||
} else if (hasModules) {
|
||||
globalConfigNode.modules = modules
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user