-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (36 loc) · 1.36 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
43
44
45
var gulp = require('gulp');
var foreach = require("gulp-foreach");
var zip = require("gulp-zip");
var del = require("del");
gulp.task("clean", function () {
return del(['./zipped/*', './units/*']);
});
gulp.task("make-folders", ["clean"], function(){
return gulp.src("./files/*.html")
.pipe(foreach(function(stream, file){
var fileName = file.path.substr(file.path.lastIndexOf("/")+1).split('.');
gulp.src(["./files/"+fileName[0]+".html", "./files/"+fileName[0]+".js"])
.pipe(gulp.dest("./units/"+fileName[0]))
return stream;
}));
})
gulp.task("copy-images", ["make-folders"], function(){
return gulp.src("./files/*.html")
.pipe(foreach(function(stream, file){
var fileName = file.path.substr(file.path.lastIndexOf("/")+1).split('.');
gulp.src(["./files/images/*"])
.pipe(gulp.dest("./units/"+fileName[0]+"/images/"))
return stream;
}));
})
gulp.task("default", ["copy-images"], function(){
return gulp.src("./files/*.html")
.pipe(foreach(function(stream, file){
var fileName = file.path.substr(file.path.lastIndexOf("/")+1).split('.');
console.log(fileName[0]);
gulp.src(["./units/"+fileName[0]+"/**/*"])
.pipe(zip(fileName[0]+".zip"))
.pipe(gulp.dest("./zipped"));
return stream;
}));
});