11#!/usr/bin/env node --import=tsx
22
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'
85
96const entryPointDirectories = [ '' , 'react' , 'query' , 'query/react' ]
107
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 ,
1314)
1415
1516const filePathsToContentMap = new Map < string , string > (
1617 await Promise . all (
1718 typeDefinitionEntryFiles . map (
1819 async ( filePath ) =>
19- [ filePath , await fs . readFile ( filePath , 'utf-8' ) ] as const ,
20+ [ filePath , await fs . readFile ( filePath , { encoding : 'utf-8' } ) ] as const ,
2021 ) ,
2122 ) ,
2223)
@@ -30,8 +31,8 @@ const main = async () => {
3031 const lines = content . split ( '\n' )
3132
3233 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 ] )
3536
3637 if ( allUniqueSymbols . length === 0 ) {
3738 console . log ( `${ filePath } does not have any unique symbols.` )
@@ -69,8 +70,8 @@ const main = async () => {
6970 )
7071 } )
7172
72- await fs . writeFile ( filePath , newContent )
73+ await fs . writeFile ( filePath , newContent , { encoding : 'utf-8' } )
7374 } )
7475}
7576
76- main ( )
77+ void main ( )
0 commit comments