Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 21, 2024
1 parent 14dada6 commit bd0940d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/extract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
const DEBUG = true // Set to false to disable debug logs

export async function extract(filePath: string): Promise<string> {
Expand Down Expand Up @@ -79,10 +78,12 @@ function generateDtsTypes(sourceCode: string): string {
}
}

const result = cleanOutput([...imports, '', ...dtsLines, '', ...exports, defaultExport].filter(Boolean).join('\n'))
const result = cleanOutput([...imports, '', ...dtsLines, '', ...exports].filter(Boolean).join('\n'))
const finalResult = defaultExport ? `${result}\n${defaultExport}` : result

if (DEBUG)
console.log('Final result:', result)
return result
console.log('Final result:', finalResult)
return finalResult
}

function processImport(importLine: string): string {
Expand Down Expand Up @@ -185,7 +186,7 @@ function processTypeDeclaration(declaration: string): string {
console.log(`Processing type declaration: ${declaration}`)
const lines = declaration.split('\n')
const typeName = lines[0].split('type')[1].split('=')[0].trim()
const typeBody = lines.slice(1).map(line => ` ${line.trim()}`).join('\n')
const typeBody = lines.slice(1).join('\n').trim()
const result = `export declare type ${typeName} = ${typeBody}`
if (DEBUG)
console.log(`Processed type declaration: ${result}`)
Expand Down

0 comments on commit bd0940d

Please sign in to comment.