From edb1bc09e64093bce71614014262da1d5cd41bba Mon Sep 17 00:00:00 2001
From: Lucas Gabriel Lima <lgl15@inf.ufpr.br>
Date: Mon, 5 Sep 2016 10:05:46 -0300
Subject: [PATCH] add compile function gulpfile and nodemon task

---
 gulpfile.js  | 35 +++++++++++++++++++++++++++++++----
 package.json |  2 ++
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index 2c273dc1..8f45a9a0 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,9 +1,31 @@
-var gulp = require('gulp');
-var mocha = require('gulp-mocha');
-var nodemon = require('gulp-nodemon');
+const gulp = require('gulp');
+const mocha = require('gulp-mocha');
+const nodemon = require('gulp-nodemon');
+const babel = require('gulp-babel');
+const eslint = require('gulp-eslint');
 
 
-gulp.task('default', ['browser-sync'], function() {
+/**
+ * Compile source files
+ */
+function compile() {
+    // run ESLint
+    gulp.src('src/**/*.js')
+        .pipe(eslint())
+        .pipe(eslint.format());
+
+    // compile source to ES5
+    gulp.src('src/**/*.js')
+        .pipe(babel())
+        .pipe(gulp.dest('build'));
+
+    // copy configuration file to build directory
+    gulp.src('config.json')
+        .pipe(gulp.dest('build'));
+
+}
+
+gulp.task('default', function() {
 
 });
 
@@ -18,9 +40,14 @@ gulp.task('test', function(){
     })
 });
 
+gulp.task('watch', [], () => {
+    compile();
+});
+
 gulp.task('run', function () {
   nodemon({
     script: 'server.js',
+    tasks: ['watch'],
     ext: 'js html',
     env: { 'NODE_ENV': 'development' }
   })
diff --git a/package.json b/package.json
index c09906f2..85051562 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,8 @@
     "chai": "^3.5.0",
     "chai-http": "^3.0.0",
     "gulp": "^3.9.1",
+    "gulp-babel": "^6.1.2",
+    "gulp-eslint": "^3.0.1",
     "gulp-mocha": "^3.0.1",
     "gulp-nodemon": "^2.1.0",
     "gulp-plumber": "^1.1.0",
-- 
GitLab