-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.mjs
43 lines (37 loc) · 1.14 KB
/
gulpfile.mjs
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
import { deleteAsync } from 'del';
import { mkdir, readFile, writeFile } from 'fs/promises';
import gulp from 'gulp';
import Jimp from 'jimp';
import yaml from 'js-yaml';
import pkg from './package.json' with { type: 'json' };
export function clean() {
return deleteAsync('dist/**');
}
function copyFiles() {
return gulp.src('src/_locales/**', { base: 'src' }).pipe(gulp.dest('dist'));
}
function copyConnectorFiles() {
return gulp.src('src/connector/package.json').pipe(gulp.dest('lib'));
}
async function createIcons() {
const dist = `dist/public/images`;
await mkdir(dist, { recursive: true });
const icon = await Jimp.read('src/resources/x.png');
return Promise.all(
[16, 19, 38, 48, 128].map((size) =>
icon.clone().resize(size, size).write(`${dist}/icon_${size}.png`),
),
);
}
async function manifest() {
const data = yaml.load(await readFile('src/manifest.yml', 'utf8'));
// Strip alphabetic suffix
data.version = pkg.version.replace(/-[^.]*/, '');
await writeFile(`dist/manifest.json`, JSON.stringify(data));
}
export const copyAssets = gulp.parallel(
copyFiles,
copyConnectorFiles,
createIcons,
manifest,
);