-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (55 loc) · 1.77 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* jshint node: true */
'use strict';
var RSVP = require('rsvp');
var DeployPluginBase = require('ember-cli-deploy-plugin');
function airbrakeConfig(context) {
var env = context.config.build.environment;
var config = context.project.config(env);
return config.airbrake || {};
}
module.exports = {
name: 'ember-cli-deploy-airbrake',
createDeployPlugin: function(options) {
var DeployPlugin = DeployPluginBase.extend({
name: options.name,
// If ember-cli-airbrake is installed we can use the config
defaultConfig: {
projectId: function(context) {
return airbrakeConfig(context).projectId;
},
projectKey: function(context) {
return airbrakeConfig(context).projectKey;
}
},
requiredConfig: ['projectId', 'projectKey'],
didActivate: function(context) {
var airbrake = require('airbrake').createClient(
this.readConfig('projectId'),
this.readConfig('projectKey')
);
var env = context.deployTarget;
var revisionData = context.revisionData;
var revisionKey = revisionData && revisionData.activatedRevisionKey;
var deployment = {
env: env,
rev: revisionKey,
repo: null
};
var plugin = this;
var trackDeployment = RSVP.denodeify(
airbrake.trackDeployment.bind(airbrake)
);
return trackDeployment(deployment).then(function(params) {
plugin.log(
'Notified Airbrake about ' +
params.env + ' deployment of revision ' + params.rev
);
return RSVP.resolve(params);
}, function(error) {
return RSVP.reject(error);
});
}
});
return new DeployPlugin();
}
};