From d918bb568c80e063b3006532e9e6e527c01ac243 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 23 Jun 2019 12:09:43 +0100 Subject: [PATCH 1/2] Ignore empty examples directories (don't add to import menu) --- packages/node_modules/@node-red/registry/lib/library.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/registry/lib/library.js b/packages/node_modules/@node-red/registry/lib/library.js index 1eea6ed56..fcb5e1eac 100644 --- a/packages/node_modules/@node-red/registry/lib/library.js +++ b/packages/node_modules/@node-red/registry/lib/library.js @@ -51,7 +51,9 @@ function getFlowsFromPath(path) { } i++; }) - + if (!result.hasOwnProperty("f")) { + reject(result); + } resolve(result); }) }); @@ -63,7 +65,7 @@ function addNodeExamplesDir(module,path) { return getFlowsFromPath(path).then(function(result) { exampleFlows = exampleFlows||{}; exampleFlows[module] = result; - }); + }, function() { return; }); } function removeNodeExamplesDir(module) { delete exampleRoots[module]; From c4f4115bcbce847f89e8997c5d859b886969cf48 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sat, 29 Jun 2019 01:16:02 +0100 Subject: [PATCH 2/2] better handle example file at any depth --- packages/node_modules/@node-red/registry/lib/library.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/node_modules/@node-red/registry/lib/library.js b/packages/node_modules/@node-red/registry/lib/library.js index fcb5e1eac..a8ca8a775 100644 --- a/packages/node_modules/@node-red/registry/lib/library.js +++ b/packages/node_modules/@node-red/registry/lib/library.js @@ -51,9 +51,6 @@ function getFlowsFromPath(path) { } i++; }) - if (!result.hasOwnProperty("f")) { - reject(result); - } resolve(result); }) }); @@ -63,9 +60,10 @@ function getFlowsFromPath(path) { function addNodeExamplesDir(module,path) { exampleRoots[module] = path; return getFlowsFromPath(path).then(function(result) { + if (JSON.stringify(result).indexOf('{"f":') === -1) { return; } exampleFlows = exampleFlows||{}; exampleFlows[module] = result; - }, function() { return; }); + }); } function removeNodeExamplesDir(module) { delete exampleRoots[module];