-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
45 lines (40 loc) · 1.19 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
const gulp = require('gulp');
const clean = require('gulp-clean');
const fs = require('fs');
const yaml = require("js-yaml");
let settings = yaml.safeLoad(fs.readFileSync("./.env", 'utf8'));
let deployPaths = settings.deployPaths;
let copyPaths = [
"./**/*",
"!./node_modules/",
"!./node_modules/**",
"!./node_modules/**/*"
];
gulp.task('delete-old-sdk-modules', function (done) {
for(let path of deployPaths) {
try {
if (fs.existsSync(path)) {
gulp.src(path, {read: false}).pipe(clean({force: true}));
console.log("deleted " + path);
}
} catch (err) {
console.error("skiped " + path, err);
}
}
setTimeout(() => done(), 1000);
});
gulp.task('copy-new-sdk', function (done) {
for(let path of deployPaths) {
try {
if(!fs.existsSync(path)) {
fs.mkdirSync(path);
}
gulp.src(copyPaths).pipe(gulp.dest(path));
console.log("copied " + path);
} catch (err) {
console.error("skiped " + path, err);
}
}
done();
});
gulp.task('deploy', gulp.series('delete-old-sdk-modules', 'copy-new-sdk'));