File tree Expand file tree Collapse file tree 8 files changed +458
-352
lines changed Expand file tree Collapse file tree 8 files changed +458
-352
lines changed Original file line number Diff line number Diff line change
1
+ import { extractDeclarations } from './src/extractor'
2
+ import { readFile } from 'node:fs/promises'
3
+ import { join } from 'node:path'
4
+
5
+ const filePath = join ( __dirname , 'test/fixtures/input/example/0002.ts' )
6
+ const sourceCode = await readFile ( filePath , 'utf-8' )
7
+
8
+ console . log ( 'Source code:' )
9
+ console . log ( sourceCode )
10
+ console . log ( '\n' + '=' . repeat ( 50 ) + '\n' )
11
+
12
+ const declarations = extractDeclarations ( sourceCode , filePath )
13
+
14
+ console . log ( 'Extracted declarations:' )
15
+ declarations . forEach ( ( decl , index ) => {
16
+ console . log ( `${ index + 1 } . Kind: ${ decl . kind } ` )
17
+ console . log ( ` Name: ${ decl . name } ` )
18
+ console . log ( ` Text: ${ decl . text } ` )
19
+ console . log ( ` IsExported: ${ decl . isExported } ` )
20
+ console . log ( ` IsTypeOnly: ${ decl . isTypeOnly } ` )
21
+ console . log ( ' ---' )
22
+ } )
Original file line number Diff line number Diff line change @@ -60,17 +60,26 @@ async function findFiles(config: DtsGenerationConfig): Promise<string[]> {
60
60
const rootPath = resolve ( config . cwd , config . root )
61
61
62
62
for ( const pattern of config . entrypoints ) {
63
- const glob = new Glob ( pattern )
64
-
65
- // Scan for matching files
66
- for await ( const file of glob . scan ( {
67
- cwd : rootPath ,
68
- absolute : true ,
69
- onlyFiles : true
70
- } ) ) {
71
- // Skip .d.ts files and node_modules
72
- if ( ! file . endsWith ( '.d.ts' ) && ! file . includes ( 'node_modules' ) ) {
73
- files . push ( file )
63
+ // Check if pattern is an absolute path to a specific file
64
+ if ( pattern . startsWith ( '/' ) && pattern . endsWith ( '.ts' ) ) {
65
+ // It's an absolute file path
66
+ if ( ! pattern . endsWith ( '.d.ts' ) && ! pattern . includes ( 'node_modules' ) ) {
67
+ files . push ( pattern )
68
+ }
69
+ } else {
70
+ // It's a glob pattern
71
+ const glob = new Glob ( pattern )
72
+
73
+ // Scan for matching files
74
+ for await ( const file of glob . scan ( {
75
+ cwd : rootPath ,
76
+ absolute : true ,
77
+ onlyFiles : true
78
+ } ) ) {
79
+ // Skip .d.ts files and node_modules
80
+ if ( ! file . endsWith ( '.d.ts' ) && ! file . includes ( 'node_modules' ) ) {
81
+ files . push ( file )
82
+ }
74
83
}
75
84
}
76
85
}
You can’t perform that action at this time.
0 commit comments