-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
42 lines (34 loc) · 1.2 KB
/
gulpfile.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
const fs = require('fs'),
gulp = require('gulp'),
clean = require('gulp-clean'),
include = require('gulp-include'),
rename = require('gulp-rename'),
zip = require('gulp-zip');
gulp.task('clean', function() {
return gulp.src('dist', {read: false})
.pipe(clean());
});
gulp.task('build', gulp.series('clean', function() {
return Promise.all([
gulp.src('index.js')
.pipe(include())
.on('error', console.log)
.pipe(gulp.dest('dist')),
gulp.src('partials/*.html')
.pipe(gulp.dest('dist/partials')),
gulp.src('module.json')
.pipe(gulp.dest('dist'))
])
}));
gulp.task('release', function() {
let moduleInfo = JSON.parse(fs.readFileSync('module.json')),
moduleId = moduleInfo.id,
moduleVersion = moduleInfo.version,
zipFileName = `${moduleId}-v${moduleVersion}.zip`;
console.log(`Packaging ${zipFileName}`);
return gulp.src('dist/**/*', { base: 'dist/'})
.pipe(rename((path) => path.dirname = `${moduleId}/${path.dirname}`))
.pipe(zip(zipFileName))
.pipe(gulp.dest('.'));
});
gulp.task('default', gulp.series('build', 'release'));