(body)
| 136 | // } |
| 137 | |
| 138 | function getExports(body) { |
| 139 | return body.filter((node) => { |
| 140 | return (node.type === 'ExpressionStatement' || |
| 141 | node.type === 'ExportDefaultDeclaration' || node.type === 'ExportNamedDeclaration') |
| 142 | }).map((node) => { |
| 143 | // ES6 default export |
| 144 | if (node.type === 'ExportDefaultDeclaration') { |
| 145 | // console.log('node', node) |
| 146 | const { declaration } = node |
| 147 | const name = declaration.name || declaration.id.name |
| 148 | return { |
| 149 | isDefault: true, |
| 150 | name: name, |
| 151 | statement: `export default ${name}` |
| 152 | } |
| 153 | } |
| 154 | // ES6 named export |
| 155 | if (node.type === 'ExportNamedDeclaration') { |
| 156 | const { declaration } = node |
| 157 | return { |
| 158 | isDefault: false, |
| 159 | name: getName(declaration), |
| 160 | statement: 'todo' |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | const { left, right } = node.expression |
| 165 | const leftValue = resolveLeft(left) |
| 166 | const rightValue = resolveRight(right) |
| 167 | // Check if main export |
| 168 | const isDefault = leftValue === 'module.exports' |
| 169 | return { |
| 170 | isDefault: isDefault, |
| 171 | name: rightValue, |
| 172 | statement: `${leftValue} = ${rightValue}` |
| 173 | } |
| 174 | }) |
| 175 | } |
| 176 | |
| 177 | function getReturnStatment(body) { |
| 178 | return body.filter((node) => { |
no test coverage detected