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

BrowserSync + Gulp with Vagrant not refreshing
gulp-tslint return undefined when required
Gulp watch only runs once
Gulp watch not working with imported files but works with main file
Gulp watch for css doesn't work
Using gulp for compiling of changed files only
How to run gulp task in visual studio code?
BrowserSync with custom URL
Multi-tenancy and Semantic UI
Display total number of errors with Gulp Jshint
Gulp watch entire folder & compile saved file
elixir.queueTask is undefined
gulp : browserify then concat files
parse error on vinyl source stream on gulp browserify babelify project
Bitters error (“Undefined variable: $font-stack-system”)
Gulp Babel Issue Using Foundation

Categories

HOME
kendo-ui-angular2
typo3
mysqli
gaussian
grid
mediarecorder
psexec
genexus
ionic-native
software-collections
subprocess
soap-client
wowza
fetch
aws-sdk-cpp
swift3.1
tag-cloud
css-float
simd
reportlab
web-parts
samba
jquery-easyui
hapijs
legend-properties
bug-reporting
tcpdf
handle
aws-certificate-manager
rollupjs
mongoose-im
gulp-jshint
formtastic
cloudformation
request-uri
hierarchy
folder
eclipse-jdt
bootcamp
incapsula
powerbi-embedded
geocomplete
certbot
ansible-inventory
jibx
azure-web-roles
google-cloud-powershell
codepen
chrome-custom-tabs
audio-fingerprinting
dynamic-linking
fluent-nhibernate-mapping
jenkins-docker
nsalert
acceleo
sqlproj
indoor-positioning-system
git-push
particle-system
change-password
bytearray
3d-rendering
razorengine
chomsky-normal-form
containstable
angular-promise
transport
android-togglebutton
winforms-interop
eaaccessory
litedb
crtdbg.h
caption
uiblureffect
qf-test
diffmerge
go-gin
powershell-v1.0
worklight-appcenter
nsmutableurlrequest
webshim
email-headers
randomaccessfile
fade
tlbimp
xrandr
azure-scheduler
boost.build
waveout
nude.js
nserror
datejs
code-organization
xpolog
jqtransform
meego-harmattan
lwp
viewdata
nyromodal
database-agnostic
silverlight-2.0
for-xml
onresize
high-load

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