-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpHelper.js
59 lines (53 loc) · 1.91 KB
/
gulpHelper.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
47
48
49
50
51
52
53
54
55
56
57
58
59
const fs = require('node:fs');
const {
ignoreSvgFiles,
ignoreFiles,
copyFiles,
buildWidgets,
npmInstall,
deleteFoldersRecursive,
} = require('./buildHelper');
function gulpTasks(gulp, adapterName, root, src, additionalCopy) {
gulp.task('widget-0-clean', done => {
deleteFoldersRecursive(`${src}build`);
deleteFoldersRecursive(`${root}/widgets`);
done();
});
additionalCopy = additionalCopy || [];
gulp.task('widget-1-npm', async () => npmInstall(src));
gulp.task('widget-2-compile', async () => buildWidgets(__dirname, src));
gulp.task('widget-3-copy', () => Promise.all([
gulp.src([`${src}build/*.js`]).pipe(gulp.dest(`widgets/${adapterName}`)),
gulp.src([`${src}build/img/*`]).pipe(gulp.dest(`widgets/${adapterName}/img`)),
gulp.src([`${src}build/*.map`]).pipe(gulp.dest(`widgets/${adapterName}`)),
gulp.src([
`${src}build/static/**/*`,
...ignoreFiles(src),
]).pipe(gulp.dest(`widgets/${adapterName}/static`)),
gulp.src([
...additionalCopy,
...copyFiles(src),
]).pipe(gulp.dest(`widgets/${adapterName}/static/js`)),
gulp.src([`${src}src/i18n/*.json`]).pipe(gulp.dest(`widgets/${adapterName}/i18n`)),
new Promise(resolve =>
setTimeout(() => {
if (fs.existsSync(`widgets/${adapterName}/static/media`) &&
!fs.readdirSync(`widgets/${adapterName}/static/media`).length
) {
fs.rmdirSync(`widgets/${adapterName}/static/media`)
}
resolve();
}, 500)
)
]));
gulp.task('widget-build', gulp.series(['widget-0-clean', 'widget-1-npm', 'widget-2-compile', 'widget-3-copy']));
}
module.exports = {
ignoreSvgFiles,
ignoreFiles,
copyFiles,
buildWidgets,
npmInstall,
deleteFoldersRecursive,
gulpTasks,
};