Skip to content

Commit 993ce46

Browse files
author
Caolan McMahon
committed
add support for minifying local branches
1 parent dd610d8 commit 993ce46

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/builder.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,15 @@ exports.exportMinified = function (wd, treeish, path, output_dir, callback) {
7373
*/
7474

7575
exports.exportAllMinified = function (wd, path, output_dir, callback) {
76-
git.getTags(wd, function (err, tags) {
76+
async.parallel({
77+
tags: async.apply(git.getTags, wd),
78+
branches: async.apply(git.getBranches, wd)
79+
},
80+
function (err, data) {
7781
if (err) return callback(err);
82+
var trees = data.tags.concat(data.branches).concat(['HEAD']);
7883

79-
async.forEach(tags.concat(['HEAD']), function (treeish, cb) {
84+
async.forEach(trees, function (treeish, cb) {
8085
var outdir = _path.join(output_dir, treeish);
8186
exports.exportMinified(wd, treeish, path, outdir, cb)
8287
}, callback);

lib/git.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@ exports.getTags = function (wd, callback) {
5656
};
5757

5858

59+
/**
60+
* Gets a list of local branches.
61+
*
62+
* @param {String} wd
63+
* @param {Function} callback
64+
* @api public
65+
*/
66+
67+
exports.getBranches = function (wd, callback) {
68+
exports.cmd(wd, ['branch'], function (err, output) {
69+
if (err) return callback(err);
70+
var branches = output.split('\n').slice(0, -1).map(function (b) {
71+
return b.substr(2);
72+
});
73+
callback(null, branches);
74+
});
75+
};
76+
77+
5978
/**
6079
* Recurses through tree objects below a given path, returning all
6180
* blobs. The treeish argument can be a tag, commit or branch.

0 commit comments

Comments
 (0)