-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
39 lines (36 loc) · 1.23 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
var gulp = require('gulp'),
print = require('gulp-print').default,
rename = require('gulp-rename'),
clean = require('gulp-clean'),
change = require('gulp-change');
gulp.task('clear-demos', function () {
return gulp.src("./documentation-demos/")
.pipe(clean());
});
gulp.task('prepare-demos', gulp.series('clear-demos', function (done) {
gulp.src([
"**/index.html",
"**/styles.css",
"**/script.js"
])
.pipe(change(function (content) {
content = content.replace('<link rel="stylesheet" href="styles.css" />', "");
content = content.replace('api-key.js', "demo-api-key.js");
return content.replace('<script src="script.js"></script>', "");
}))
.pipe(rename(function (path) {
if (path.basename === "index" && path.extname === ".html") {
path.basename = "demo";
}
if (path.basename === "styles" && path.extname === ".css") {
path.basename = "demo";
}
if (path.basename === "script" && path.extname === ".js") {
path.basename = "demo";
}
}))
.pipe(gulp.dest("./documentation-demos/"))
.pipe(print());
done();
}));
gulp.task('default', gulp.series('prepare-demos'));