react-dropit
Version:
Uploading files is now easier :))
67 lines (43 loc) • 924 B
JavaScript
var gulp = require('gulp'),
babel = require('gulp-babel'),
nodemon = require('gulp-nodemon'),
path = require('path'),
fs = require('fs');
class GulpMain {
constructor () {
this.checkWatch()
}
checkWatch () {
if (process.env.NODE_ENV === 'local')
this.watch = true
else
this.watch = false
}
dist () {
return './dist'
}
source () {
return path.resolve(__dirname, 'src') + '/**/*.js?(x)'
}
buildSource (done) {
const build = (cb) => {
gulp.src([this.source(), '!./*/**/app.js?(x)', '!./*/**/gulp*.js', '!./*/**/__mocks__/*.js', '!./*/**/__tests__/*.js'])
.pipe(babel())
.pipe(gulp.dest(this.dist()))
.on('end', () => {
if (typeof done === 'function')
cb()
})
}
if (this.watch) {
build(done)
gulp.watch(this.source(), build)
} else {
build(done)
}
}
run (done) {
this.buildSource(done)
}
}
module.exports = new GulpMain