Permalink
Browse files

* change gulp watch task.

  • Loading branch information...
1 parent e7ccc87 commit e87a8785a8f67a9eff7b722d75bb23c304c186a6 @Catouse Catouse committed Dec 8, 2016
Showing with 29 additions and 19 deletions.
  1. +29 −19 gulpfile.js
View
@@ -440,6 +440,34 @@ gulp.task('build', function(callback) {
}, type);
});
+function startWatchSrc(name) {
+ if(name === 'lib') name = 'seperate';
+ gulp.watch(["./src/less/**/*"], function(event) {
+ buildBundle(name, function() {
+ console.log(''.green + (' WATCH ' + name.bold + ' COMPLETED. ').yellow.inverse);
+ }, 'less');
+ });
+
+ gulp.watch(["./src/js/**/*"], function(event) {
+ if(event.path && (event.path.lastIndexOf('src/js/colorset.js') > -1) || event.path.lastIndexOf('src\\js\\colorset.js') > -1) return;
+ buildBundle(name, function() {
+ console.log(''.green + (' WATCH ' + name.bold + ' COMPLETED. ').yellow.inverse);
+ }, 'js');
+ });
+
+ gulp.watch(["./src/fonts/**/*"], function(event) {
+ buildBundle(name, function() {
+ console.log(''.green + (' WATCH ' + name.bold + ' COMPLETED. ').yellow.inverse);
+ }, 'resource');
+ });
+}
+
+gulp.task('watch', function(callback) {
+ var name = process.argv[3] || 'dist';
+ if(name && name[0] === '-') name = name.substr(1);
+ startWatchSrc(name);
+});
+
['dist', 'doc', 'theme', 'lib'].forEach(function(name) {
var depsTasks = (name == 'dist' || name == 'doc') ? ['minJSON'] : [];
gulp.task(name, depsTasks, function(callback) {
@@ -451,25 +479,7 @@ gulp.task('build', function(callback) {
});
gulp.task('watch:' + name, function() {
- if(name === 'lib') name = 'seperate';
- gulp.watch(["./src/less/**/*"], function(event) {
- buildBundle(name, function() {
- console.log(''.green + (' WATCH ' + name.bold + ' COMPLETED. ').yellow.inverse);
- }, 'less');
- });
-
- gulp.watch(["./src/js/**/*"], function(event) {
- if(event.path && (event.path.lastIndexOf('src/js/colorset.js') > -1) || event.path.lastIndexOf('src\\js\\colorset.js') > -1) return;
- buildBundle(name, function() {
- console.log(''.green + (' WATCH ' + name.bold + ' COMPLETED. ').yellow.inverse);
- }, 'js');
- });
-
- gulp.watch(["./src/fonts/**/*"], function(event) {
- buildBundle(name, function() {
- console.log(''.green + (' WATCH ' + name.bold + ' COMPLETED. ').yellow.inverse);
- }, 'resource');
- });
+ startWatchSrc(name);
});
});

0 comments on commit e87a878

Please sign in to comment.