traverse(ast, { ObjectProperty(astPath) { if (astPath.node.value.name === self.argv.parentName) { if (astPath.parent.properties.some(element => { return element.key.name === 'children'; })) { isChildren = true; } astPath.skip(); } } });
traverse(ast, { ArrayExpression(astPath) { const parent = astPath.findParent(p => p.isObjectProperty); const properties = parent.parent.properties; properties.forEach(element => { if (element.value && element.value.name === self.argv.parentName) { astPath.node.elements.push(self.generateEl()); astPath.skip(); } }); } });