forked from live-codes/livecodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle-types.js
More file actions
31 lines (25 loc) · 713 Bytes
/
Copy pathbundle-types.js
File metadata and controls
31 lines (25 loc) · 713 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
29
30
31
const fs = require('fs');
const path = require('path');
const dts = require('dts-bundle');
const outDir = 'build/sdk/';
const outFile = 'livecodes.d.ts';
const outPath = outDir + outFile;
// delete if exists
try {
fs.unlinkSync(path.resolve(outPath));
} catch {}
const options = {
name: 'livecodes',
main: outDir + '**/*.d.ts',
out: outFile,
removeSource: true,
};
dts.bundle(options);
// patch
const content = fs.readFileSync(path.resolve(outPath), 'utf8');
const patched = content
.replace(/export \* from 'livecodes\/.*;/g, '')
.replace(/livecodes\/index/g, 'livecodes')
.replace(/\/\/\s.*/g, '')
.replace(/[\r\n]{2,}/g, '\n');
fs.writeFileSync(path.resolve(outPath), patched, 'utf8');