Skip to content

Commit 9f40a09

Browse files
committed
Fix Ember, Angular plugins
1 parent a70e9dc commit 9f40a09

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

Gruntfile.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ module.exports = function(grunt) {
2525
// custom browserify transformer to re-write plugins to
2626
// self-register with Raven via addPlugin
2727
function AddPluginBrowserifyTransformer() {
28-
return function (file, options) {
28+
return function (file) {
2929
return through(function (buf, enc, next) {
3030
buf = buf.toString('utf8');
3131
if (/plugins/.test(file)) {
32-
buf += "\nRaven.addPlugin(module.exports);";
32+
buf += "\nrequire('../src/singleton').addPlugin(module.exports);";
3333
}
3434
this.push(buf);
3535
next();
@@ -69,6 +69,8 @@ module.exports = function(grunt) {
6969
};
7070

7171
var pluginCombinations = combine(grunt.file.expand('plugins/*.js'));
72+
73+
var pluginCombinations = [['plugins/ember.js']];
7274
var pluginConcatFiles = _.reduce(pluginCombinations, function (dict, comb) {
7375
var key = _.map(comb, function (plugin) {
7476
return path.basename(plugin, '.js');
@@ -100,9 +102,11 @@ module.exports = function(grunt) {
100102
},
101103
plugins: {
102104
files: pluginConcatFiles,
103-
transform: [
104-
[ new AddPluginBrowserifyTransformer() ]
105-
]
105+
options: {
106+
transform: [
107+
[ new AddPluginBrowserifyTransformer() ]
108+
]
109+
}
106110
},
107111
test: {
108112
src: 'test/**/*.test.js',

plugins/angular.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function install() {
1313
/*jshint validthis:true*/
1414
var Raven = this;
1515
function RavenProvider() {
16-
this.$get = ['$window', function($window, $log) {
16+
this.$get = ['$window', function($window) {
1717
return Raven;
1818
}];
1919
}
@@ -58,6 +58,4 @@ function install() {
5858
});
5959
}
6060

61-
module.exports = {
62-
install: install
63-
};
61+
module.exports = install;

plugins/ember.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@ function install(Ember) {
2929
});
3030
}
3131

32-
module.exports = {
33-
install: install
34-
};
32+
module.exports = install;

src/raven.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,18 @@ Raven.prototype = {
149149
* @return {Raven}
150150
*/
151151
install: function() {
152+
var self = this;
152153
if (this.isSetup() && !this._isRavenInstalled) {
153-
TraceKit.report.subscribe(this._handleStackInfo);
154+
TraceKit.report.subscribe(function () {
155+
// maintain 'self'
156+
self._handleStackInfo.apply(self, arguments);
157+
});
154158

155159
// Install all of the plugins
156160
each(this._plugins, function(_, plugin) {
157-
plugin();
161+
var args = plugin.slice(1);
162+
plugin = plugin[0];
163+
plugin.apply(self, args);
158164
});
159165

160166
this._isRavenInstalled = true;
@@ -316,9 +322,11 @@ Raven.prototype = {
316322
},
317323

318324
addPlugin: function(plugin /*arg1, arg2, ... argN*/) {
319-
this._plugins.push(plugin);
325+
var rest = Array.prototype.slice.call(arguments, 1);
320326
if (this._isRavenInstalled) {
321-
plugin.install.apply(this, Array.prototype.slice.call(arguments, 1));
327+
plugin.install.apply(this, rest);
328+
} else {
329+
this._plugins.push([plugin].concat(rest));
322330
}
323331
return this;
324332
},

0 commit comments

Comments
 (0)