diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 9f3ea07ec7cacb13fa1f6460b858bf85464db4e8..5073c55a2fc9dbecccccacf5d808ccc0b979eaef 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -14,40 +14,41 @@ const Cache = require('gulp-file-cache'); const jsdoc = require('gulp-jsdoc3'); +const mkdirp = require('mkdirp'); + const cache = new Cache(); function createLogDir() { const logDirPath = 'build/logs'; - fs.access(logDirPath, fs.F_OK, (err) => { - if (err) { - console.info(`Logs directory not found, creating it.`); - fs.mkdir(logDirPath, 0o700, (dirErr) => { - console.error(`Failed to create logs directory.\n\tError: ${dirErr}`); - }); - } + mkdirp(logDirPath, (err) => { + if(err) console.error(err); }); } -/** -* Compile source files -*/ -gulp.task('compile', () => { - createLogDir(); +gulp.task('lint', () => { // run ESLint gulp.src('src/**/*.js') .pipe(eslint()) .pipe(eslint.format()); +}) + +/** +* Compile source files +*/ +gulp.task('compile', ['lint'], () => { // 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(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')); + + createLogDir(); }); gulp.task('build', ['compile']); diff --git a/package.json b/package.json index 87652e4ad3aadf65ba1a5cdf3b06b8f20da31854..2249eef5b875af1b2d79d75bacc2c88d6b318b5f 100644 --- a/package.json +++ b/package.json @@ -50,12 +50,14 @@ "gulp-cli": "^1.2.2", "gulp-eslint": "^3.0.1", "gulp-file-cache": "0.0.1", + "gulp-function": "^1.3.6", "gulp-jsdoc3": "^0.3.0", "gulp-mocha": "^3.0.1", "gulp-nodemon": "^2.1.0", "gulp-plumber": "^1.1.0", "gulp-rename": "^1.2.2", "gulp-uglify": "^2.0.0", - "jsdoc": "^3.4.1" + "jsdoc": "^3.4.1", + "mkdirp": "^0.5.1" } }