forked from angularity/node-angularity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
69 lines (60 loc) · 1.62 KB
/
index.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict';
var path = require('path');
var gulp = require('gulp'),
runSequence = require('run-sequence'),
pluginRegistry = require('plugin-registry');
var taskYargsRun = require('./lib/util/task-yargs-run');
var defaultTaskPlugins = [
'html',
'css',
'javascript',
'test',
'build',
'release',
'server',
'watch',
'init',
'webstorm'
].map(function parseDefaultPluginDefinition(taskName) {
return {
name: taskName,
requirePath: path.resolve(__dirname, 'tasks', taskName),
category: 'task',
isDefault: true
};
});
var angularityJson;
try {
angularityJson = require(path.resolve('angularity.json'));
}
catch (ex) {
// Do nothing
}
var configTaskPlugins = (angularityJson && angularityJson.plugins) || [];
if (configTaskPlugins.constructor !== Array) {
throw new Error('Plugins defined in angularity.json should be an array');
}
var pluginContext = {
toolPath: __dirname
};
pluginRegistry
.get('angularity')
.context(pluginContext)
.add(defaultTaskPlugins)
.add(configTaskPlugins);
pluginRegistry
.get('angularity')
.getAllOfCategory('task')
.forEach(function eachTaskPlugin(definition) {
var plugin = definition.plugin;
// Task plugins are expected to export a function which should be called with an instance of taskYargsRun
if (typeof plugin !== 'function') {
throw new Error('Plugin named ' + definition.name + ' does not export a function');
}
var taskDefinition = plugin({
taskYargsRun: taskYargsRun,
gulp: gulp,
runSequence: runSequence
});
taskYargsRun.taskYargs.register(taskDefinition);
});