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

Gulpfile not working when module.exports references a Gulp task not a function?
Use gulp to process bowser files
Getting an error when trying to serve the app using browser-sync
Can't Sprite using gulp.spritesmith
How can I make build variables available to all JS files in gulp?
Gulp not installed globally?
gulp-useref deep folders error
use gulp+browserify+reactify, can't emit exit when got a ReactifyError
gulp-browserstack and gulp-cucumber don't seem to play nicely together
Gulp - Babel - EcmaScript-6 - Redux / Unhandled stream error in pipe
Delete all files using gulp except once that match pattern
Gulp task 'inject:vendor' does not inject Bower dependencies
Why do you open a gulp src pipe when you use gulp-watch?
Atom action performed on save
Gulp BrowserSync not working with SCSS
run gulp-clean-css options in gulp-inline

Categories

HOME
optimization
compression
locale
jenkins-pipeline
pelican
gaussian
x86-64
django-middleware
redhawksdr
query-string
procmon
jquery-select2
handlebars.js
restheart
pyodbc
normals
popup
bootstrap-datetimepicker
spring-webflow
coccinelle
pumping-lemma
android-wear-2.0
windowserror
grunt-contrib-uglify
datanucleus
rollupjs
android-cursorloader
angular2-changedetection
osgi-bundle
paper-trail-gem
textview
exacttarget
key-bindings
ng2-bootstrap
cocoa-scripting
armadillo
socketcluster
redbean
contenteditable
test-kitchen
f#-fake
spring-ide
nao-robot
spring-cloud-bus
px4
fluent-nhibernate-mapping
bioperl
sharpssh
multi-select
instaparse
sprockets
kik
supervised-learning
clique
chomsky-normal-form
custom-build-step
calc
fadein
askbot
kramdown
ios8-share-extension
imageicon
maven-antrun-plugin
personality-insights
adempiere
musicbrainz
stereotype
gmaps4jsf
perfect-scrollbar
data-quality-services
javadb
nsnotificationcenter
ios-enterprise
django-tests
azure-caching
8-puzzle
nsnumber
angularjs-select2
pudb
pageload
mmo
system.transactions
rfc822
jquery-ui-map
mvcmailer
jmesa
sqlbuddy
nsundomanager
method-call
response-time
lgpl
system-analysis
atmega16

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