1
1
#!/usr/bin/env node --import=tsx
2
2
3
- import fs from 'node:fs/promises'
4
- import path from 'node:path'
5
- import { fileURLToPath } from 'node:url'
6
-
7
- const __dirname = fileURLToPath ( new URL ( '.' , import . meta. url ) )
3
+ import * as fs from 'node:fs/promises'
4
+ import * as path from 'node:path'
8
5
9
6
const entryPointDirectories = [ '' , 'react' , 'query' , 'query/react' ]
10
7
11
- const typeDefinitionEntryFiles = entryPointDirectories . map ( ( filePath ) =>
12
- path . resolve ( __dirname , '..' , 'dist' , filePath , 'index.d.ts' ) ,
8
+ const typeDefinitionEntryFiles = entryPointDirectories . flatMap (
9
+ ( filePath ) =>
10
+ [
11
+ path . join ( import . meta. dirname , '..' , 'dist' , filePath , 'index.d.ts' ) ,
12
+ path . join ( import . meta. dirname , '..' , 'dist' , filePath , 'index.d.mts' ) ,
13
+ ] as const ,
13
14
)
14
15
15
16
const filePathsToContentMap = new Map < string , string > (
16
17
await Promise . all (
17
18
typeDefinitionEntryFiles . map (
18
19
async ( filePath ) =>
19
- [ filePath , await fs . readFile ( filePath , 'utf-8' ) ] as const ,
20
+ [ filePath , await fs . readFile ( filePath , { encoding : 'utf-8' } ) ] as const ,
20
21
) ,
21
22
) ,
22
23
)
@@ -30,8 +31,8 @@ const main = async () => {
30
31
const lines = content . split ( '\n' )
31
32
32
33
const allUniqueSymbols = lines
33
- . filter ( ( line ) => / d e c l a r e c o n s t ( \w + ) \ : u n i q u e s y m b o l ; / . test ( line ) )
34
- . map ( ( line ) => line . match ( / d e c l a r e c o n s t ( \w + ) \ : u n i q u e s y m b o l ; / ) ?. [ 1 ] )
34
+ . filter ( ( line ) => / d e c l a r e c o n s t ( \w + ) : u n i q u e s y m b o l ; / . test ( line ) )
35
+ . map ( ( line ) => line . match ( / d e c l a r e c o n s t ( \w + ) : u n i q u e s y m b o l ; / ) ?. [ 1 ] )
35
36
36
37
if ( allUniqueSymbols . length === 0 ) {
37
38
console . log ( `${ filePath } does not have any unique symbols.` )
@@ -69,8 +70,8 @@ const main = async () => {
69
70
)
70
71
} )
71
72
72
- await fs . writeFile ( filePath , newContent )
73
+ await fs . writeFile ( filePath , newContent , { encoding : 'utf-8' } )
73
74
} )
74
75
}
75
76
76
- main ( )
77
+ void main ( )
0 commit comments