var gulp = require('gulp'); var uglify = require('gulp-uglify'); var rename = require('gulp-rename'); var clean = require('gulp-clean'); var srcmaps = require('gulp-sourcemaps'); var mocha = require('gulp-mocha'); var jsdoc = require('gulp-jsdoc3'); var srcPath = './'; var srcFile = 'es5-ff-spa-loader.js'; var distPath = 'dist/'; var testSrc = 'test/*.js'; gulp.task('clean', function() { return gulp.src(distPath).pipe(clean()); }); gulp.task('buildScript', ['test'], function() { gulp.src(srcFile, {cwd: srcPath}).pipe(gulp.dest(distPath)); }); gulp.task('buildScriptMin', ['buildScript'], function() { gulp.src(srcFile, {cwd: srcPath}) .pipe(srcmaps.init()) .pipe(uglify({/*preserveComments: 'license'*/})) .pipe(rename({ extname: '.min.js' })) .pipe(srcmaps.write('.')) .pipe(gulp.dest(distPath)); }); gulp.task('testMocha',['clean'], function() { process.env.JUNIT_REPORT_PATH = 'test/data/report.xml'; return gulp.src(testSrc, {read: false}).pipe(mocha({reporter: 'mocha-jenkins-reporter'})); }); gulp.task('buildJSDoc', function (cb) { var jsdocConfig = { opts: { destination: 'dist/jsdoc' }, templates: { thema: 'cerulean', navType: 'vertical', linenums: true } }; gulp.src(srcFile, {read: false}).pipe(jsdoc(jsdocConfig, cb)); }); gulp.task('test', ['clean','testMocha']); gulp.task('build', ['test','buildScript','buildScriptMin'/*,'buildJSDoc'*/]);