news/js/gulpfile.js

89 строки
2.2 KiB
JavaScript
Исходник Обычный вид История

2016-02-12 00:36:29 +03:00
/**
2016-07-23 22:32:42 +03:00
* Nextcloud - News
2016-02-12 00:36:29 +03:00
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2012, 2014
*/
2016-02-12 19:51:35 +03:00
/*jslint node: true */
2016-02-12 00:36:29 +03:00
'use strict';
2016-02-12 19:46:14 +03:00
const gulp = require('gulp'),
2016-02-12 00:36:29 +03:00
ngAnnotate = require('gulp-ng-annotate'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
KarmaServer = require('karma').Server,
phpunit = require('gulp-phpunit'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps');
2016-02-12 20:01:08 +03:00
// Configuration
2016-02-12 19:51:35 +03:00
const buildTarget = 'app.min.js';
2016-02-12 19:46:14 +03:00
const phpunitConfig = __dirname + '/../phpunit.xml';
const karmaConfig = __dirname + '/karma.conf.js';
const destinationFolder = __dirname + '/build/';
const sources = [
2016-02-12 00:36:29 +03:00
'app/App.js', 'app/Config.js', 'app/Run.js',
'controller/**/*.js',
'filter/**/*.js',
'service/**/*.js',
'gui/**/*.js',
'plugin/**/*.js',
'utility/**/*.js',
'directive/**/*.js'
];
2016-02-12 19:46:14 +03:00
const testSources = ['tests/**/*.js'];
2016-02-12 19:56:08 +03:00
const phpSources = ['../**/*.php', '!../js/**', '!../vendor/**'];
2016-02-12 20:01:08 +03:00
const watchSources = sources.concat(testSources).concat(['*.js']);
2016-02-12 19:46:14 +03:00
const lintSources = watchSources;
2016-02-12 00:36:29 +03:00
2016-02-12 20:01:08 +03:00
// tasks
2016-02-12 00:36:29 +03:00
gulp.task('default', ['lint'], () => {
return gulp.src(sources)
.pipe(ngAnnotate())
.pipe(sourcemaps.init())
2016-02-12 19:51:35 +03:00
.pipe(concat(buildTarget))
2016-02-12 00:36:29 +03:00
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(destinationFolder));
});
gulp.task('lint', () => {
2016-02-12 19:46:14 +03:00
return gulp.src(lintSources)
2016-02-12 00:36:29 +03:00
.pipe(jshint())
2016-02-12 19:46:14 +03:00
.pipe(jshint.reporter('default'))
2016-02-12 00:36:29 +03:00
.pipe(jshint.reporter('fail'));
});
gulp.task('watch', () => {
2016-02-12 19:46:14 +03:00
gulp.watch(watchSources, ['default']);
2016-02-12 00:36:29 +03:00
});
gulp.task('karma', (done) => {
new KarmaServer({
configFile: karmaConfig,
singleRun: true
}, done).start();
2016-02-12 19:51:35 +03:00
});
2016-02-12 00:36:29 +03:00
gulp.task('watch-karma', (done) => {
new KarmaServer({
configFile: karmaConfig,
autoWatch: true
}, done).start();
2016-02-12 19:51:35 +03:00
});
2016-02-12 00:36:29 +03:00
gulp.task('phpunit', () => {
2016-03-25 17:31:17 +03:00
return gulp.src(phpSources)
2016-02-12 00:36:29 +03:00
.pipe(phpunit('phpunit', {
configurationFile: phpunitConfig
}));
});
gulp.task('watch-phpunit', () => {
gulp.watch(phpSources, ['phpunit']);
});