From: Gustavo Martin Morcuende Date: Thu, 27 Aug 2015 00:53:06 +0000 (+0200) Subject: gulp-my-tasks: wirdepoptions, show more informartion if verbose argument X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=95783d8993f307a847df1e3f04948e6f8d572e62;p=JavaScriptForFun gulp-my-tasks: wirdepoptions, show more informartion if verbose argument --- diff --git a/gulp/gulp-my-tasks/tasks/tasks.config.js b/gulp/gulp-my-tasks/tasks/tasks.config.js index 8710931..033ebb1 100644 --- a/gulp/gulp-my-tasks/tasks/tasks.config.js +++ b/gulp/gulp-my-tasks/tasks/tasks.config.js @@ -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; } }; diff --git a/gulp/gulp-my-tasks/tasks/tasks.js b/gulp/gulp-my-tasks/tasks/tasks.js index ba71d7c..3f26aa3 100644 --- a/gulp/gulp-my-tasks/tasks/tasks.js +++ b/gulp/gulp-my-tasks/tasks/tasks.js @@ -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)); });