-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (40 loc) · 1.18 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
/*!
* upstage <https://github.com/upstage/upstage-cli>
*
* Copyright (c) 2015, Brian Woodward.
* Licensed under the MIT License.
*/
'use strict';
var merge = require('merge-deep');
var path = require('path');
var gulp = require('gulp');
var build = require('./lib/tasks/build');
var push = require('./lib/tasks/push');
function Application () {
if (!(this instanceof Application)) {
return new Application();
}
}
Application.prototype.run = function(dirs, argv, done) {
var options = merge({
templates: path.join(__dirname, 'lib', 'templates')
}, argv);
var tasks = dirs.map(function (dir) {
return {
cwd: path.resolve(dir),
name: path.basename(path.resolve(dir))
};
}).filter(Boolean);
tasks.forEach(function (task) {
gulp.task('build-' + task.name, build(merge({}, {cwd: task.cwd}, options)));
gulp.task('push-' + task.name, ['build-' + task.name], push(merge({}, {cwd: task.cwd}, options)));
gulp.task(task.name, ['build-' + task.name, 'push-' + task.name]);
});
gulp.start.apply(gulp, tasks.map(prop('name')).concat(done));
};
function prop(key) {
return function (obj) {
return obj[key];
};
}
module.exports = Application();