gulp


how wrench plugin is useful for in gulp


I was learning gulp. I had come thru following code.
wrench.readdirSyncRecursive('./gulp').filter(function(file) {
return (/\.(js|coffee)$/i).test(file);
}).map(function(file) {
require('./gulp/' + file);
});
Can somebody help me to understand what above code is useful for?
This will load all js or coffee files in the gulp directory in order to load all gulp tasks, so you dont have to manually import new gulp tasks, just create whatevergulptask.js inside '/gulp' directory and you can use it from the command line.
Another advange of doing it like this is that you dont have a huge gulpfile.js with millions of tasks and lines of code, as instead you have a whatevergulptask.js per TASK, just a good practice cos the gulpfile grows pretty fast
Example gulpfile.js
/**
* Welcome to your gulpfile!
* The gulp tasks are splitted in several files in the gulp directory
* because putting all here was really too long
*/
'use strict';
var gulp = require('gulp');
var wrench = require('wrench');
/**
* This will load all js or coffee files in the gulp directory
* in order to load all gulp tasks
*/
wrench.readdirSyncRecursive('./gulp').filter(function (file) {
return (/\.(js|coffee)$/i).test(file);
}).map(function (file) {
require('./gulp/' + file);
});
/**
* Default task clean temporaries directories and launch the
* main optimization build task
*/
gulp.task('default', ['clean'], function () {
gulp.start('build');
});
YOUR FOLDER STRUCTURE
gulp/
build.js
whatevergulptask.js
...

Related Links

the task can't be called by watch module.
I can't get the data-uri() function to work on gulp.js to base64 an image on mac
How to inject bower dependencies in karma.conf.js file with gulp?
Getting Libsass Gulp Susy to work together
Gulp compass without config.rb
gulp-webserver: Default to index.html if available, else show directories
gulp-uglify notify on failing build
Declaring optional dependencies
gulp html minification error
Can an IIFE be added to a browserify bundle?
Gulp: Error Messages and Notifications with Plumber
Gulp - gulp-load-plugins not working
How to configure Gulp task to copy bower resources
gulp-jscs doesn't output anything when used in gulp-watch pipeline
ES6 project does not compile because modules not found
Gulp - can't set multiple relative destinations

Categories

HOME
ckan
botframework
marie
primefaces
mobile
pyspark
postgresql-9.3
display
aix
readdir
bitbucket
hiveql
coordinates
multipartform-data
procmon
virtualhost
webpack-dev-server
ephesoft
obd-ii
normals
chef-recipe
android-notifications
logstash-configuration
swift3.1
dat.gui
dompdf
game-engine
windows-phone
indri
civicrm
single-page-application
gnu-screen
connection-pooling
prepros
inspec
libxml2
windows-10-mobile
csproj
kundera
delphi-2010
kubectl
qt-designer
jcr
border-layout
area
nsdateformatter
blueimp
php-mongodb
qt-quick
rexx
amazon-rds-aurora
bootstrap-carousel
mef
togglebutton
serialversionuid
jenkins-docker
cc
stripes
computed-properties
vitamio
system-integration
paypal-subscriptions
opendolphin
transport
traminer
firebase-tools
esri-arc-engine
android-relativelayout
kuka-krl
.net-reflector
facebook-likebox
zend-db-table
xrandr
qmainwindow
system.transactions
filedialog
systrace
nude.js
eeprom
facebook-winjs-sdk
httppostedfilebase
flexbuilder
xpolog
method-call
iphone-maps
mysql-logic
qprocess
dojox.gfx
retrospectiva
projectgen
disk-based

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App