-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb-tools.js
53 lines (42 loc) · 2.02 KB
/
web-tools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var _ = require('lodash'),
args = require('yargs').argv,
getExt = require('./gulp-get-ext.js'),
metadata = require('./gulp-metadata.js'),
tasks = require('./gulp-tasks.js'),
StreamCache = require('./misc/stream-cache.js'),
PipelineCache = require('./misc/pipeline-cache.js'),
MiddlewareCache = require('./misc/middleware-cache.js');
module.exports = {
applyTo: function (gulp, configFactory, plugins) {
var runningTask = _.get(args, '_[0]') || 'default';
// Get config based on the arguments given
gulp.webToolsConfig = configFactory(gulp, runningTask, args);
// Create a StreamCache on this instance, to help save some time down the road
gulp.streamCache = new StreamCache();
// Create a PipelineCache on this instance, to store pipelines
gulp.pipelineCache = new PipelineCache(gulp);
// Add the default pipelines to the cache
gulp.pipelineCache.put('html', '../pipelines/pipeline.html.js');
gulp.pipelineCache.put('css', '../pipelines/pipeline.css.js');
gulp.pipelineCache.put('js', '../pipelines/pipeline.js.js');
gulp.pipelineCache.put('svg', '../pipelines/pipeline.svg.js');
// Create a MiddlewareCache on this instance, to store server middleware
gulp.middlewareCache = new MiddlewareCache();
// Add the default middleware to the cache
gulp.middlewareCache.put('utilities', '../middleware/middleware.utilities.js');
gulp.middlewareCache.put('simple-site', '../middleware/middleware.simple-site.js');
gulp.middlewareCache.put('single-page-app', '../middleware/middleware.single-page-app.js');
// Apply gulp enhancements
getExt.applyTo(gulp);
metadata.applyTo(gulp);
tasks.applyTo(gulp);
// This prevents node from throwing a warning about memory leaks: http://stackoverflow.com/questions/9768444
process.setMaxListeners(0);
_.each(plugins, function plugItIn(plugin) {
if (_.isFunction(plugin)) {
plugin(gulp);
}
});
return gulp;
}
};