-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.js
50 lines (39 loc) · 1.29 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';
const DeployPluginBase = require('ember-cli-deploy-plugin');
const ScmTable = require('./lib/scm-table');
const LegacyTable = require('./lib/legacy-table');
module.exports = {
name: 'ember-cli-deploy-display-revisions',
createDeployPlugin(options) {
let DeployPlugin = DeployPluginBase.extend({
name: options.name,
defaultConfig: {
amount(context) {
return context.commandOptions.amount || 10;
},
revisions(context) {
return context.revisions;
}
},
displayRevisions(/* context */) {
let table;
let 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"));
let 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();
}
};