-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.js
49 lines (43 loc) · 1.51 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
var RSVP = require('rsvp');
var gitty = require("gitty");
var DeployPluginBase = require('ember-cli-deploy-plugin');
module.exports = {
name: 'ember-cli-deploy-git-tag',
createDeployPlugin: function(options) {
var DeployPlugin = DeployPluginBase.extend({
name: options.name,
defaultConfig: {
revisionKey: function(context) {
return context.commandOptions.revision || (context.revisionData && context.revisionData.revisionKey);
},
deployTag: function(context) {
var revisionKey = this.readConfig("revisionKey");
var deployTarget = context.deployTarget;
return ["deploy", deployTarget, revisionKey].join('-');
}
},
configure: function(/*context*/) {
this.log('validating config', { verbose: true });
['deployTag', 'revisionKey'].forEach(this.applyDefaultConfigProperty.bind(this));
this.log('config ok', { verbose: true });
},
didDeploy: function(context) {
var tag = this.readConfig("deployTag");
var repo = (context._Git || gitty)(".");
var _this = this;
return new RSVP.Promise(function(resolve, reject) {
repo.createTag(tag, function(e) {
if (e) {
_this.log(e, { color: 'red' });
reject(e);
} else {
_this.log("tagged "+tag, { verbose: true });
resolve();
}
});
});
}
});
return new DeployPlugin();
}
};