|
1 | | -import { readFile, writeFile } from 'node:fs/promises'; |
| 1 | +import { cp } from 'node:fs/promises'; |
2 | 2 |
|
3 | | -const rawTypesDTS = new URL('../typings/rawDataTypes.d.ts', import.meta.url); |
4 | 3 | const rawIndexDTS = new URL('../typings/index.d.ts', import.meta.url); |
5 | | - |
6 | | -const rawTypesMDTS = new URL('../typings/rawDataTypes.d.mts', import.meta.url); |
7 | 4 | const rawIndexMTS = new URL('../typings/index.d.mts', import.meta.url); |
8 | 5 |
|
9 | | -const [rawTypesString, rawIndexString] = await Promise.all([ |
10 | | - readFile(rawTypesDTS, 'utf8'), |
11 | | - readFile(rawIndexDTS, 'utf8'), |
12 | | -]); |
13 | | - |
14 | | -/** |
15 | | - * |
16 | | - * @param {string} source |
17 | | - * @param {[from: string, to: string][]} imports |
18 | | - */ |
19 | | -function updateImports(source, imports) { |
20 | | - return imports.reduce((code, [from, to]) => { |
21 | | - return code.replaceAll(from, to); |
22 | | - }, source); |
23 | | -} |
24 | | - |
25 | | -/** @type {[string, string][]} */ |
26 | | -const rawTypesImports = [ |
27 | | - ['./index.js', './index.mjs'], // |
28 | | -]; |
29 | | - |
30 | | -/** @type {[string, string][]} */ |
31 | | -const rawIndexImports = [ |
32 | | - ['./rawDataTypes.js', './rawDataTypes.mjs'], // |
33 | | -]; |
34 | | - |
35 | | -const rawTypesMDTSString = updateImports(rawTypesString, rawTypesImports); |
36 | | -const rawIndexMTSString = updateImports(rawIndexString, rawIndexImports); |
37 | | - |
38 | | -await Promise.all([writeFile(rawTypesMDTS, rawTypesMDTSString), writeFile(rawIndexMTS, rawIndexMTSString)]); |
| 6 | +await cp(rawIndexDTS, rawIndexMTS); |
0 commit comments