diff --git a/gulp/build/build-cli.js b/gulp/build/build-cli.js index f28aa6d..0b91f6e 100644 --- a/gulp/build/build-cli.js +++ b/gulp/build/build-cli.js @@ -1,13 +1,9 @@ import gulp from 'gulp'; import PATHS from './../helpers/src-paths'; -import sourcemaps from 'gulp-sourcemaps'; -import babel from 'gulp-babel'; +import helpers from './../helpers/gulp-helpers'; + +const {buildES6} = helpers; gulp.task('build-cli', done => { - return gulp.src(PATHS.CLI_SRC_JS) - .pipe(sourcemaps.init()) - .pipe(babel()) - .on('error', done) - .pipe(sourcemaps.write('.')) - .pipe(gulp.dest('lib')); + return buildES6(PATHS.CLI_SRC_JS, PATHS.CLI_DEST, done); }); diff --git a/gulp/build/build-static.js b/gulp/build/build-static.js index 4d10f6f..3cba6b2 100644 --- a/gulp/build/build-static.js +++ b/gulp/build/build-static.js @@ -1,8 +1,8 @@ import gulp from 'gulp'; import PATHS from './../helpers/src-paths'; +import helpers from './../helpers/gulp-helpers'; -import babel from 'gulp-babel'; -import sourcemaps from 'gulp-sourcemaps'; +const {buildES6} = helpers; gulp.task('build-static-not-js', () => { return gulp.src([PATHS.APP_STATIC_ALL, '!**/*.js']) @@ -10,12 +10,7 @@ gulp.task('build-static-not-js', () => { }); gulp.task('build-static-js', done => { - return gulp.src(PATHS.APP_STATIC_JS) - .pipe(sourcemaps.init()) - .pipe(babel()) - .on('error', done) - .pipe(sourcemaps.write('.')) - .pipe(gulp.dest(PATHS.APP_STATIC_DEST)); + return buildES6(PATHS.APP_STATIC_JS, PATHS.APP_STATIC_DEST, done); }); gulp.task('build-static', ['build-static-js', 'build-static-not-js']); diff --git a/gulp/helpers/gulp-helpers.js b/gulp/helpers/gulp-helpers.js index ad7af57..36bd3e1 100644 --- a/gulp/helpers/gulp-helpers.js +++ b/gulp/helpers/gulp-helpers.js @@ -1,4 +1,7 @@ +import gulp from 'gulp'; import shellJs from 'shelljs'; +import sourcemaps from 'gulp-sourcemaps'; +import babel from 'gulp-babel'; function shellExec(cmd, silent, callback) { shellJs.exec(cmd, {silent: silent}, (code, stdout, stderr) => { @@ -10,4 +13,16 @@ function shellExec(cmd, silent, callback) { }); } -export default {shellExec}; +function buildES6(src, dest, callback) { + return gulp.src(src) + .pipe(sourcemaps.init()) + .pipe(babel()) + .on('error', callback) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(dest)); +} + +export default { + shellExec, + buildES6 +}; diff --git a/gulp/tests/build-tests.js b/gulp/tests/build-tests.js index de3f792..6d5b1b8 100644 --- a/gulp/tests/build-tests.js +++ b/gulp/tests/build-tests.js @@ -1,14 +1,9 @@ import gulp from 'gulp'; import PATHS from './../helpers/src-paths'; +import helpers from './../helpers/gulp-helpers'; -import sourcemaps from 'gulp-sourcemaps'; -import babel from 'gulp-babel'; +const {buildES6} = helpers; gulp.task('build-tests', done => { - return gulp.src(PATHS.TEST_SRC_JS) - .pipe(sourcemaps.init()) - .pipe(babel()) - .on('error', done) - .pipe(sourcemaps.write('.')) - .pipe(gulp.dest(PATHS.TEST_DEST)); + return buildES6(PATHS.TEST_SRC_JS, PATHS.TEST_DEST, done); });