Last active
January 3, 2016 05:39
-
-
Save silviopaganini/8417474 to your computer and use it in GitHub Desktop.
Gulp require snippet for all devDependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp = require('gulp'); | |
pkg = require('./package.json'); | |
for (k in pkg.devDependencies) { | |
v = pkg.devDependencies[k]; | |
a = k.indexOf('gulp-') > -1 ? k.split('gulp-')[1] : k; | |
GLOBAL[a] = require(k); | |
} |
Coffeescript just in case
pkg = require './package.json'
GLOBAL[k.replace(/^gulp-/, '')] = require(k) for k, v of pkg.devDependencies
@kewah why not filter it from package.json
too?
require('matchdep')
.filterDev('gulp-*', './package.json')
.forEach(function(module) {
global[module.replace(/^gulp-/, '')] = require(module);
});
@stryju by default it loads the nearest package.json
@kewah ah, true! my bad :)
// load all gulp tasks matching the `gulp*` pattern to include gulp itself
require('matchdep')
.filterDev('gulp*') //by default it loads the nearest package.json
.forEach(function(module) {
global[module.replace(/^gulp-/, '')] = require(module);
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same goal, but using matchdep