update helper functions

pull/479/head
Cory LaViska 2021-06-28 08:53:31 -04:00
rodzic 42fb6c7100
commit 94a5c6244e
2 zmienionych plików z 12 dodań i 14 usunięć

Wyświetl plik

@ -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() {

Wyświetl plik

@ -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 }));
}
}
});
});