From 94a5c6244ec1ed5f9aa46b3f48eb49abac19bb13 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 28 Jun 2021 08:53:31 -0400 Subject: [PATCH] update helper functions --- docs/assets/plugins/metadata/metadata.js | 13 ++++++------- scripts/make-vscode-data.js | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/docs/assets/plugins/metadata/metadata.js b/docs/assets/plugins/metadata/metadata.js index 40bdba901..b3ceb3fe5 100644 --- a/docs/assets/plugins/metadata/metadata.js +++ b/docs/assets/plugins/metadata/metadata.js @@ -246,16 +246,15 @@ const allComponents = []; metadata.modules.map(module => { - module.exports.find(ex => { + module.exports.map(ex => { if (ex.kind === 'custom-element-definition') { const tagName = ex.name; const className = ex.declaration.name; - const component = Object.assign( - { className, tagName }, - module?.declarations.find(dec => dec.name === 'default') - ); + const component = module?.declarations.find(dec => dec.name === 'default'); - allComponents.push(component); + if (component) { + allComponents.push(Object.assign(component, { className, tagName })); + } } }); }); @@ -264,7 +263,7 @@ } function getComponent(metadata, tagName) { - return getAllComponents(metadata).find(component => (component.tagName = tagName)); + return getAllComponents(metadata).find(component => component.tagName === tagName); } function getMetadata() { diff --git a/scripts/make-vscode-data.js b/scripts/make-vscode-data.js index 6741a16cd..d1fb615b6 100644 --- a/scripts/make-vscode-data.js +++ b/scripts/make-vscode-data.js @@ -9,20 +9,19 @@ import mkdirp from 'mkdirp'; const metadata = JSON.parse(fs.readFileSync('./dist/custom-elements.json', 'utf8')); -function getAllComponents() { +function getAllComponents(metadata) { const allComponents = []; metadata.modules.map(module => { - module.exports.find(ex => { + module.exports.map(ex => { if (ex.kind === 'custom-element-definition') { const tagName = ex.name; const className = ex.declaration.name; - const component = Object.assign( - { className, tagName }, - module?.declarations.find(dec => dec.name === 'default') - ); + const component = module?.declarations.find(dec => dec.name === 'default'); - allComponents.push(component); + if (component) { + allComponents.push(Object.assign(component, { className, tagName })); + } } }); });