gulp.task('help', plugins.taskListing);
gulp.task('default', ['help']);
-
/**
* @ngdoc function
*
log('*** Checking HTML source files with HTMLHint ***');
- return gulp.src(config.templates)
+ return gulp.src(config.html)
.pipe(plugins.if(args.verbose, plugins.print()))
.pipe(plugins.htmlhint(config.htmlHintConfigurationFile))
.pipe(plugins.htmlhint.failReporter());
-
});
/**
*
* @returns {Stream}
*/
-gulp.task('wiredep', function() {
+gulp.task('wireup', function() {
- log('*** Wiring bower dependencies into html ***');
+ log('*** Wiring bower dependencies and injecting files into html ***');
var wiredep = require('wiredep').stream;
var jsFiles = args.stubs ? [].concat(config.jsFilesWithoutSpecs, config.jsFilesStubs) : config.jsFilesWithoutSpecs;
*
* @returns {Stream}
*/
-gulp.task('wiredepkarma', function() {
+gulp.task('wireupkarma', function() {
log('*** Wiring bower dependencies into karma.conf.js ***');
* @description
* Runs HTTP server.
*/
-gulp.task('server', ['wiredep'], function(done) {
+gulp.task('server', function(done) {
var environment = 'development';
if (args.environment) {
*
* @returns {Stream}
*/
-gulp.task('test', ['vet', 'wiredepkarma'], function(done) {
+gulp.task('test', ['vet', 'wireupkarma'], function(done) {
log('*** Run tests once ***');
* @description
* Run specs and wait. Watch for file changes and re-run tests on each change
*/
-gulp.task('autotest', ['wiredepkarma'], function(done) {
+gulp.task('autotest', ['wireupkarma'], function(done) {
log('*** Run tests and wait ***');
*
* @returns {stream} The stream.
*/
-gulp.task('build', ['wiredep', 'test', 'templatecache'], function() {
+gulp.task('build', ['wireup', 'test', 'templatecache'], function() {
log('*** Building application for production - Optimizing assets - HTML,CSS,JS ***');
log('*** Creating AngularJS $templateCache ***');
return gulp
- .src(config.templates)
+ .src(config.html)
.pipe(plugins.if(args.verbose, plugins.bytediff.start()))
.pipe(plugins.minifyHtml({
empty: true,
* Runs HTTP server.
*
* @param {string=} [environment='development'] development or production environments.
- * @returns {undefined}
+ * @returns {stream} The stream
*/
function server(environment) {
var nodeOptions = {
})
.on('start', function () {
log('HTTP server started');
+ synchronization(environment);
})
.on('crash', function () {
log('HTTP server crashed');
var difference = (data.savings > 0) ? ' smaller.' : ' larger.';
return data.fileName + ' is ' + data.percent + '%' + difference;
}
+
+/**
+ * @ngdoc function
+ *
+ * @description
+ * Files synchronization.
+ *
+ * @param {string=} [environment='development'] development or production environments.
+ * @returns {undefined}
+ */
+function synchronization(environment) {
+
+ log('Files synchronization');
+
+ var jsFiles = args.stubs ? [].concat(config.jsFilesWithoutSpecs, config.jsFilesStubs) : config.jsFilesWithoutSpecs;
+
+ switch (environment) {
+ case 'production':
+ jsFiles = jsFiles.concat(config.html);
+ plugins.watch(jsFiles, {
+ name: 'Files synchronization',
+ verbose: true,
+ readDelay: 200
+ }, plugins.batch(function (events, done) {
+ // TODO: gulp.start going to be deprecated in gulp 4.0.0 version. Alternatives?
+ gulp.start('build', done);
+ }));
+ break;
+ default:
+ plugins.watch(jsFiles, {
+ name: 'Files synchronization',
+ verbose: true,
+ readDelay: 200
+ }, plugins.batch(function (events, done) {
+ // TODO: gulp.start going to be deprecated in gulp 4.0.0 version. Alternatives?
+ gulp.start('wireup', done);
+ }));
+ break;
+ }
+}