forked from benwinding/react-admin-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (47 loc) · 1.38 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
46
47
48
49
50
51
52
53
54
55
56
const del = require("del");
const gulp = require("gulp");
const gulpSequence = require("gulp-sequence");
const exec = require("child_process").exec;
const execCmd = (cmd, directory) => {
console.log(`running $ "${cmd}" in dir: [${directory}]`);
const child = exec(cmd, { cwd: directory });
child.stdout.on("data", function(data) {
console.log(data);
});
child.stderr.on("data", function(data) {
console.error(data);
});
return new Promise((resolve, reject) => {
child.on("close", resolve);
});
};
const conf = {
watchSrc: "./src/**/*",
copyFrom: ["./src/**/*", "./package.json", "./dist/**/*"],
copyTo: "./src-demo/node_modules/react-admin-firebase",
output: {
dir: `./dist/**/*`
},
demo: {
root: "./src-demo"
}
};
gulp.task("clean", function() {
return del([conf.output.dir]);
});
gulp.task("build", function() {
return execCmd("yarn build");
});
gulp.task("prepare-demo", function() {
return execCmd("yarn", './src-demo');
});
gulp.task("copy-to-demo", function() {
return gulp.src(conf.copyFrom, { base: "." }).pipe(gulp.dest(conf.copyTo));
});
gulp.task("watch-and-copy-to-demo", function() {
// Execute commands in series
execCmd("yarn watch", '.');
gulp.watch(conf.output.dir, ["copy-to-demo"]);
execCmd("sleep 10 && yarn start", 'src-demo');
});
gulp.task("start-demo", gulpSequence("prepare-demo", "watch-and-copy-to-demo"));