Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

update to work with fastboot 1.0 #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 36 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,51 @@ var merge = require('lodash/merge');
var replace = require('broccoli-string-replace');
var mergeTrees = require('broccoli-merge-trees');
var path = require('path');
const fastbootTransform = require('fastboot-transform');

module.exports = {
name: 'ember-cli-rollbar',
included: function(app) {
options: {
nodeAssets: {
'rollbar': {
enabled: this.enabled,
import: {
include: ['vendor/rollbar.js', 'vendor/rollbar-module.js'],
processTree(input) {
return fastbootTransform(input);
}
}
}
}
},
included(app) {
var config = this.project.config(this.app.env).rollbar || {};
var defaultEnabled = this.app.env !== 'development' && this.app.env !== 'test';
var enabled = config.enabled == null ? defaultEnabled : config.enabled;
if (process.env.EMBER_CLI_FASTBOOT !== 'true') {
app.import('vendor/rollbar.js', {
prepend: true
});
app.import('vendor/rollbar-module.js');
}
this.enabled = config.enabled == null ? defaultEnabled : config.enabled;

this._super.included.apply(this, arguments);
},
treeForVendor: function(vt) {
var vendorTree = this._super.treeForVendor(vt);

if (process.env.EMBER_CLI_FASTBOOT !== 'true') {
var config = this.project.config(this.app.env).rollbar || {};
config = merge({
enabled: this.app.env !== 'development' && this.app.env !== 'test',
captureUncaught: true,
payload: {
environment: this.app.env
}
}, config);
var clientTree = replace(path.join(__dirname, 'client'), {
files: ['rollbar.js'],
pattern: {
match: /ROLLBAR_CONFIG/g,
replacement: JSON.stringify(config)
}
});
var config = this.project.config(this.app.env).rollbar || {};
config = merge({
enabled: this.app.env !== 'development' && this.app.env !== 'test',
captureUncaught: true,
payload: {
environment: this.app.env
}
}, config);
var clientTree = replace(path.join(__dirname, 'client'), {
files: ['rollbar.js'],
pattern: {
match: /ROLLBAR_CONFIG/g,
replacement: JSON.stringify(config)
}
});

return mergeTrees([vendorTree, clientTree], {
overwrite: true
});
} else {
return vendorTree;
}
return mergeTrees([vendorTree, clientTree], {
overwrite: true
});
}
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
"ember-addon"
],
"dependencies": {
"broccoli-string-replace": "^0.1.1",
"broccoli-merge-trees": "^1.1.1",
"broccoli-string-replace": "^0.1.1",
"ember-cli-babel": "^5.1.6",
"fastboot-transform": "^0.1.2",
"lodash": "^4.11.1"
},
"ember-addon": {
Expand Down
Loading