-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.babel.js
43 lines (32 loc) · 1.2 KB
/
gulpfile.babel.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
import {buildJs, createLintJs, watchJs} from './tasks/js';
import {buildJson, watchJson} from './tasks/json';
import {globs, paths, watchOptions} from './tasks/config.js';
import {iconify, watchIcon} from './tasks/icon';
import {access} from 'fs';
import del from 'del';
import gulp from 'gulp';
import {join} from 'path';
import manifest from './src/manifest';
import {promisify} from 'util';
import zipper from 'gulp-zip';
const zipFileName = `${manifest.name} ${manifest.version}.zip`;
const clean = () => del(paths.build);
const lint = createLintJs();
const build = gulp.series(clean, lint,
gulp.parallel(iconify, buildJs, buildJson));
const checkVersion = () => promisify(access)(join(paths.release, zipFileName))
.then(() => {
throw new Error(`There is already a release "${zipFileName}"`);
},
() => true);
const zip = () => gulp.src(globs.build)
.pipe(zipper(zipFileName))
.pipe(gulp.dest(paths.release));
const release = gulp.series(build, checkVersion, zip);
const watcher = () => {
watchIcon(watchOptions);
watchJs(watchOptions);
watchJson(watchOptions);
};
const watch = gulp.series(clean, watcher);
export {clean, lint, build, release, watch, watch as default};