-
Notifications
You must be signed in to change notification settings - Fork 0
/
postbuild.ts
37 lines (33 loc) · 1.11 KB
/
postbuild.ts
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
import { copyFile, mkdir, readdir } from 'fs/promises';
async function main () {
// Copy manifest and options to dist
copyFile('./src/manifest.json', './dist/manifest.json');
copyFile('./src/options.html', './dist/options.html');
// Copy icons to dist
try {
await mkdir('./dist/icons');
} catch (err) {} finally {
try {
const icons = await readdir('./src/icons');
for (const icon of icons) {
copyFile(`./src/icons/${icon}`, `./dist/icons/${icon}`);
}
} catch (e) {
console.error('No icons found. Please add icons to ./src/icons');
}
}
// Copy images to dist
try {
await mkdir('./dist/images');
} catch (err) {} finally {
try {
const images = await readdir('./src/images');
for (const image of images) {
copyFile(`./src/images/${image}`, `./dist/images/${image}`);
}
} catch (e) {
console.error('No images found. Please add images to ./src/images');
}
}
}
main();