-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.js
50 lines (39 loc) · 1.32 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
'use strict';
var DeployPluginBase = require('ember-cli-deploy-plugin');
var ScmTable = require('./lib/scm-table');
var LegacyTable = require('./lib/legacy-table');
module.exports = {
name: 'ember-cli-deploy-display-revisions',
createDeployPlugin: function(options) {
var DeployPlugin = DeployPluginBase.extend({
name: options.name,
defaultConfig: {
amount: function(context) {
return context.commandOptions.amount || 10;
},
revisions: function(context) {
return context.revisions;
}
},
displayRevisions: function(/* context */) {
var table;
var revisions = this.readConfig('revisions');
if(!revisions || revisions.length === 0) {
this.log("Could not display latest revisions because no revisions were found in context.", {color: 'yellow'});
return;
}
revisions = revisions.slice(0, this.readConfig("amount"));
var hasRevisionData = revisions.reduce(function(prev, current) {
return !prev ? false : !!current.revisionData;
}, true);
if (hasRevisionData) {
table = new ScmTable(this, revisions);
} else {
table = new LegacyTable(this, revisions);
}
table.display();
}
});
return new DeployPlugin();
}
};