-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack.js
46 lines (36 loc) · 1.3 KB
/
pack.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
const fs = require('fs');
const glob = require('glob');
const path = require('path');
async function main() {
const packageFile = fs.readFileSync('package.json', {encoding: 'utf8', flag: 'r'});
const packageJson = JSON.parse(packageFile);
delete packageJson.private;
delete packageJson.files;
delete packageJson.scripts;
delete packageJson.devDependencies;
fs.writeFileSync('dist/package.json', JSON.stringify(packageJson), {encoding: 'utf8', flag: 'w'});
fs.copyFileSync('README.md', 'dist/README.md');
fs.copyFileSync('LICENSE', 'dist/LICENSE');
if (fs.existsSync('dist/schemas')) {
fs.rmSync('dist/schemas', {recursive: true, force: true});
}
if (!fs.existsSync('dist/src')) {
return;
}
const sections = ["main", "preload", "renderer"];
for (const section of sections) {
const files = await glob(`dist/src/${section}/*.ts`);
files.forEach((file) => {
fs.renameSync(file, path.join(`dist/${section}`, path.basename(file)));
});
}
const files = await glob('dist/src/*.ts');
files.forEach((file) => {
fs.renameSync(file, path.join(`dist`, path.basename(file)));
});
fs.rmSync('dist/src', {recursive: true, force: true});
}
(async () => {
await main();
})();