-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpFile.js
74 lines (62 loc) · 1.81 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const webpack = require('webpack-stream');
const nodemon = require('gulp-nodemon');
const eslint = require('gulp-eslint-new');
const webpackConfig = require('./webpack.config.js');
const { exec } = require('child_process');
// compile our css
const sassTask = (done) => {
gulp.src('./scss/main.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./hosted'));
done();
};
// run webpack with our configurations in webpack.config.js
const jsTask = (done) => {
return webpack(webpackConfig)
.pipe(gulp.dest('./hosted'));
}
// lint our tasks as according to our .eslintrc file
const lintTask = (done) => {
gulp.src('./server/**/*.js')
.pipe(eslint({fix: true}))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
done();
}
const build = gulp.parallel(sassTask, lintTask, jsTask);
const herokuBuild = gulp.parallel(sassTask, jsTask);
// adds, commits and pushes our code to github
const gitTask = (done) => {
exec('git add . && git commit -m "auto commit" && git push', (err, stdout, stderr) =>{
console.log(stdout);
console.log(stderr);
if (err) {
//node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr ${stderr}`);
});
done();
};
const watch = (done) => {
gulp.watch('./scss/**/*.scss', sassTask);
gulp.watch(['./client/*.js', './client/*.jsx'], jsTask);
nodemon({
script: './server/app.js',
tasks: ['lintTask'],
watch: ['./server'],
});
}
module.exports = {
gitTask,
sassTask,
build,
jsTask,
lintTask,
watch,
herokuBuild,
};