Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make into an ember-addon. #8

Merged
merged 1 commit into from
Jul 1, 2014
Merged
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
42 changes: 42 additions & 0 deletions lib/ember-cli-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var path = require('path');
var fs = require('fs');

var assetRev = require('./asset-rev');

function EmberCLIAssetRev(project) {
this.project = project;
this.name = 'broccoli-asset-rev';
}

EmberCLIAssetRev.prototype.initializeOptions = function() {
var defaultOptions = {
enabled: this.app.env === 'production',
exclude: [],
extensions: ['js', 'css', 'png', 'jpg', 'gif'],
prepend: '',
replaceExtensions: ['html', 'css', 'js']
}

this.options = this.app.options.fingerprint || {};

for (var option in defaultOptions) {
if (!this.options.hasOwnProperty(option)) {
this.options[option] = defaultOptions[option];
}
}
};

EmberCLIAssetRev.prototype.postprocessTree = function (type, tree) {
if (type === 'all' && this.options.enabled) {
tree = assetRev(tree, this.options);
}

return tree;
};

EmberCLIAssetRev.prototype.included = function (app) {
this.app = app;
this.initializeOptions();
};

module.exports = EmberCLIAssetRev;
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.9",
"description": "broccoli asset revisions (fingerprint)",
"main": "lib/asset-rev.js",
"ember-addon-main": "lib/ember-cli-main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -17,7 +18,8 @@
"rev",
"fingerprint",
"cloudfront",
"cdn"
"cdn",
"ember-addon"
],
"author": "Rick Harrison",
"license": "MIT",
Expand Down