Skip to content

Commit cda7262

Browse files
committed
Source formatting.
1 parent a146b12 commit cda7262

File tree

2 files changed

+27
-39
lines changed

2 files changed

+27
-39
lines changed

bin/list.handlebars

-7
This file was deleted.

bin/travis.js

+27-32
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* @author Zeno Rocha <zno.rocha@gmail.com>
1111
*/
1212

13+
'use strict';
14+
1315
var GH_PATH = process.env.GH_PATH;
1416

1517
// -- Requires -----------------------------------------------------------------
@@ -66,13 +68,6 @@ Travis.prototype.run = function() {
6668
options.all = true;
6769
}
6870

69-
logger.logTemplate('Listing last builds for {{greenBright user}}' +
70-
'{{#if notAll}}{{greenBright "/" repo}}{{/if}}', {
71-
notAll: !options.all,
72-
user: options.user,
73-
repo: options.repo
74-
});
75-
7671
instance.list(options.user, options.repo);
7772
}
7873
};
@@ -83,26 +78,14 @@ Travis.prototype.browser = function(user, repo) {
8378

8479
Travis.prototype.list = function(user, repo) {
8580
var instance = this,
86-
options = instance.options;
87-
88-
logger.registerHelper('state', function(state) {
89-
var color = logger.clc.magentaBright;
81+
options = instance.options,
82+
header = 'Listing last builds for ' + logger.colors.green(user);
9083

91-
if (state === 'passed') {
92-
color = logger.clc.greenBright;
93-
}
94-
else if (state === 'started') {
95-
color = logger.clc.blueBright;
96-
}
97-
else if (state === 'failed') {
98-
color = logger.clc.redBright;
99-
}
100-
else if (state === 'errored') {
101-
color = logger.clc.redBright;
102-
}
84+
if (!options.all) {
85+
header += logger.colors.green('/' + repo);
86+
}
10387

104-
return color(state);
105-
});
88+
logger.log(header);
10689

10790
if (options.all) {
10891
travisCi.repos(user).get(function (err, builds) {
@@ -116,10 +99,25 @@ Travis.prototype.list = function(user, repo) {
11699
}
117100
};
118101

102+
Travis.prototype.printRepo_ = function(repo) {
103+
var options = this.options,
104+
content = logger.colors.yellow(repo.slug) + '\n';
105+
106+
if (options.detailed) {
107+
if (repo.last_build_id) {
108+
content += 'Last build #' + repo.last_build_id + ' ' + repo.last_build_state + ' ' +
109+
logger.getDuration(repo.last_build_started_at) + '\n'
110+
logger.colors.blue('https://travis-ci.org/' + repo.slug + '/builds/' + repo.last_build_id);
111+
} else {
112+
content += 'There are no builds for this repository.\n';
113+
}
114+
}
115+
116+
logger.log(content);
117+
};
118+
119119
Travis.prototype.buildsCallback_ = function(err, builds) {
120-
var instance = this,
121-
options = instance.options,
122-
repos = [];
120+
var repos = [];
123121

124122
try {
125123
err = JSON.parse(err);
@@ -140,10 +138,7 @@ Travis.prototype.buildsCallback_ = function(err, builds) {
140138
}
141139

142140
if (repos.length > 0) {
143-
logger.logTemplateFile(__dirname + '/list.handlebars', {
144-
detailed: options.detailed,
145-
repos: repos
146-
});
141+
repos.forEach(this.printRepo_, this);
147142
}
148143
};
149144

0 commit comments

Comments
 (0)