-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
28 lines (23 loc) · 767 Bytes
/
build.mjs
File metadata and controls
28 lines (23 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import url from 'url';
const commands = [
// Generate the index.d.ts file
'tsc -p tsconfig.json',
// Remove types that are supposed to be used internally
'rm -rf ./dist/src',
// Re-format the output
'npx prettier --write "dist/*.d.ts"',
];
execSync(commands.join(' && '));
const typesPath = path.join(
path.dirname(url.fileURLToPath(import.meta.url)),
'dist/index.d.ts',
);
// Insert empty line breaks between public declarations
const publicDeclaration = '/**\n * @public';
const typesContent = fs.readFileSync(typesPath, {
encoding: 'utf-8',
}).replaceAll(publicDeclaration, '\n' + publicDeclaration);
fs.writeFileSync(typesPath, typesContent, 'utf-8');