Skip to content

Commit 9d4a3c9

Browse files
committed
Fix fixUniqueSymbolExports.mts
1 parent be9f25b commit 9d4a3c9

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

packages/toolkit/scripts/fixUniqueSymbolExports.mts

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
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

96
const 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

1516
const 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) => /declare const (\w+)\: unique symbol;/.test(line))
34-
.map((line) => line.match(/declare const (\w+)\: unique symbol;/)?.[1])
34+
.filter((line) => /declare const (\w+): unique symbol;/.test(line))
35+
.map((line) => line.match(/declare const (\w+): unique symbol;/)?.[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

Comments
 (0)