diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 986652cccb3cdcfee0d659c0a69533943ae9a495..beb0e25ff52ccc30a80d22b09311cf5c0ea256cb 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -29,25 +29,25 @@ function createLogDir() { } /** - * Compile source files - */ +* Compile source files +*/ gulp.task('compile', () => { createLogDir(); // run ESLint gulp.src('src/**/*.js') - .pipe(eslint()) - .pipe(eslint.format()); + .pipe(eslint()) + .pipe(eslint.format()); // compile source to ES5 gulp.src('src/**/*.js') - .pipe(cache.filter()) // cache source files - .pipe(babel()) // compile only modified files - .pipe(cache.cache()) // cache compiled files - .pipe(gulp.dest('build')); // move compiled files to build directory + .pipe(cache.filter()) // cache source files + .pipe(babel()) // compile only modified files + .pipe(cache.cache()) // cache compiled files + .pipe(gulp.dest('build')); // move compiled files to build directory // copy configuration file to build directory gulp.src('config.json') - .pipe(gulp.dest('build')); + .pipe(gulp.dest('build')); }); gulp.task('build', ['compile']); @@ -55,17 +55,18 @@ gulp.task('build', ['compile']); gulp.task('doc', (cb) => { let config = require('./jsdoc.json'); gulp.src(['README.md', './src/**/*.js'], {read: false}) - .pipe(jsdoc(config, cb)); + .pipe(jsdoc(config, cb)); }); gulp.task('test', ['build'], () => { - gulp.src('test/test.js', {read: false}) + process.chdir('build'); + gulp.src('test/test.js', {read: false}) .pipe(mocha()) .once('error', () => { - process.exit(1); + process.exit(1); }) .once('end', () => { - process.exit(); + process.exit(); }); }); @@ -79,14 +80,14 @@ gulp.task('watch', ['compile'], () => { }); gulp.task('run', () => { - process.chdir('build'); - nodemon({ - script: 'server.js', - tasks: ['watch'], - ignore: ["test/test.js", "gulpfile.babel.js"], - ext: 'js html json', - env: { 'NODE_ENV': 'development' } - }); + process.chdir('build'); + nodemon({ + script: 'server.js', + tasks: ['watch'], + ignore: ["test/test.js", "gulpfile.babel.js"], + ext: 'js html json', + env: { 'NODE_ENV': 'development' } + }); }); gulp.task('default', ['run']); diff --git a/src/test/test.js b/src/test/test.js index e6bdd1fd0edf6ce272f73a68d6749401705859b6..f06f837ef405c00dd4bc5bdb5f5c812f722c6ccb 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -12,7 +12,9 @@ const expect = chai.expect; const should = chai.should(); // actually call the function -const server = require('../libs/app'); +const libs = `${process.cwd()}/libs`; + +const server = require(`${libs}/app`); chai.use(chaiHttp);