gulp-my-tasks: wirdepoptions, show more informartion if verbose argument
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 27 Aug 2015 00:53:06 +0000 (02:53 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 27 Aug 2015 00:53:06 +0000 (02:53 +0200)
gulp/gulp-my-tasks/tasks/tasks.config.js
gulp/gulp-my-tasks/tasks/tasks.js

index 8710931..033ebb1 100644 (file)
@@ -43,56 +43,70 @@ module.exports = function() {
     /**
      * wiredep options for index.html
      */
-    wiredepOptions: {
-      // The directory of your Bower packages. default: '.bowerrc'.directory || bower_components
-      bowerJson: bower.json,
-      // Your bower.json file contents. default: require('./bower.json')
-      directory: bower.directory,
-      // string or regexp to ignore from the injected filepath
-      ignorePath: bower.ignorePath,
-      dependencies: true,     // default: true
-      onError: function(err) {
-        console.log('wiredep error: ' + err.code);
-      },
-      onFileUpdated: function(filePath) {
-        console.log('wiredep updated file: ' + filePath);
-      },
-      onPathInjected: function(fileObject) {
-        console.log('wiredep injected file: ' + fileObject.block);
-        console.log('wiredep injected file: ' + fileObject.file);
-        console.log('wiredep injected file: ' + fileObject.path);
-      },
-      onMainNotFound: function(pkg) {
-        console.log('wiredep name of bower package without main: ' + pkg);
+    wiredepOptions: function(isVerbose) {
+      var options = {
+        // The directory of your Bower packages. default: '.bowerrc'.directory || bower_components
+        bowerJson: bower.json,
+        // Your bower.json file contents. default: require('./bower.json')
+        directory: bower.directory,
+        // string or regexp to ignore from the injected filepath
+        ignorePath: bower.ignorePath,
+        dependencies: true,     // default: true
+      };
+
+      if (isVerbose) {
+        options.onError = function (err) {
+          console.log('wiredep error: ' + err.code);
+        };
+        options.onFileUpdated = function (filePath) {
+          console.log('wiredep updated file: ' + filePath);
+        };
+        options.onPathInjected = function (fileObject) {
+          console.log('wiredep injected file: ' + fileObject.block);
+          console.log('wiredep injected file: ' + fileObject.file);
+          console.log('wiredep injected file: ' + fileObject.path);
+        };
+        options.onMainNotFound = function (pkg) {
+          console.log('wiredep name of bower package without main: ' + pkg);
+        }
       }
+
+      return options;
     },
 
     /**
      * wiredep options for karma.conf.js
      */
-    wiredepKarmaOptions: {
-      // The directory of your Bower packages. default: '.bowerrc'.directory || bower_components
-      bowerJson: bower.json,
-      // Your bower.json file contents. default: require('./bower.json')
-      directory: bower.directory,
-      // string or regexp to ignore from the injected filepath
-      ignorePath: bower.ignorePath,
-      dependencies: true,     // default: true
-      devDependencies: true, // default: false
-      onError: function(err) {
-        console.log('wiredep error: ' + err.code);
-      },
-      onFileUpdated: function(filePath) {
-        console.log('wiredep updated file: ' + filePath);
-      },
-      onPathInjected: function(fileObject) {
-        console.log('wiredep injected file: ' + fileObject.block);
-        console.log('wiredep injected file: ' + fileObject.file);
-        console.log('wiredep injected file: ' + fileObject.path);
-      },
-      onMainNotFound: function(pkg) {
-        console.log('wiredep name of bower package without main: ' + pkg);
+    wiredepKarmaOptions: function(isVerbose) {
+      var options = {
+        // The directory of your Bower packages. default: '.bowerrc'.directory || bower_components
+        bowerJson: bower.json,
+        // Your bower.json file contents. default: require('./bower.json')
+        directory: bower.directory,
+        // string or regexp to ignore from the injected filepath
+        ignorePath: bower.ignorePath,
+        dependencies: true,     // default: true
+        devDependencies: true,  // default: false
+      };
+
+      if (isVerbose) {
+        options.onError = function (err) {
+          console.log('wiredep error: ' + err.code);
+        };
+        options.onFileUpdated = function (filePath) {
+          console.log('wiredep updated file: ' + filePath);
+        };
+        options.onPathInjected = function (fileObject) {
+          console.log('wiredep injected file: ' + fileObject.block);
+          console.log('wiredep injected file: ' + fileObject.file);
+          console.log('wiredep injected file: ' + fileObject.path);
+        };
+        options.onMainNotFound = function (pkg) {
+          console.log('wiredep name of bower package without main: ' + pkg);
+        }
       }
+
+      return options;
     }
   };
 
index ba71d7c..3f26aa3 100644 (file)
@@ -96,7 +96,7 @@ module.exports = function(gulp, customConfig) {
     var jsFiles = args.stubs ? [].concat(config.jsFilesWithoutSpecs, config.jsFilesStubs) : config.jsFilesWithoutSpecs;
 
     return gulp.src(config.index)
-      .pipe(wiredep(config.wiredepOptions))
+      .pipe(wiredep(config.wiredepOptions(args.verbose ? true : false)))
       .pipe(inject(jsFiles, ''))
       .pipe(gulp.dest(config.main));
   });
@@ -116,7 +116,7 @@ module.exports = function(gulp, customConfig) {
     var wiredep = require('wiredep').stream;
 
     return gulp.src(config.karmaConf)
-      .pipe(wiredep(config.wiredepKarmaOptions))
+      .pipe(wiredep(config.wiredepKarmaOptions(args.verbose ? true : false)))
       .pipe(gulp.dest(currentDir));
   });