forked from benwinding/react-admin-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (41 loc) · 1.12 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
const { series, watch } = require('gulp');
const gulp = require("gulp");
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"
}
};
async function prepareDemo(cb) {
await execCmd("yarn", './src-demo')
cb();
}
function copyToDemo() {
return gulp.src(conf.copyFrom, { base: "." }).pipe(gulp.dest(conf.copyTo))
}
function watchAndCopy(cb) {
// body omitted
execCmd("yarn watch", '.');
watch(conf.output.dir, copyToDemo);
execCmd("sleep 10 && yarn start", 'src-demo');
}
exports['start-demo'] = series(prepareDemo, watchAndCopy);