Skip to content

Commit

Permalink
update ember-cli addon implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecraige committed Sep 15, 2014
1 parent 5aaecd3 commit 608e411
Showing 1 changed file with 34 additions and 41 deletions.
75 changes: 34 additions & 41 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
/* jshint node: true */
'use strict';

var path = require('path');
var fs = require('fs');
var mergeTrees = require('broccoli-merge-trees');
var pickFiles = require('broccoli-static-compiler');

function LiquidFire(project) {
this.project = project;
this.name = 'Liquid Fire';
}

function unwatchedTree(dir) {
return {
read: function() { return dir; },
cleanup: function() { }
};
}

LiquidFire.prototype.treeFor = function treeFor(name) {
var treePath = path.join('node_modules', 'liquid-fire');

if (name === 'templates') {
treePath = path.join(treePath, 'app-addon', 'templates');
} else {
treePath = path.join(treePath, name + '-addon');
}
var fs = require('fs');
var path = require('path');

var addon;
module.exports = {
name: 'Liquid Fire',

if (fs.existsSync(treePath)) {
addon = unwatchedTree(treePath);
}
init: function() {
this.treePaths.app = 'app-addon';
this.treePaths.templates = 'app-addon/templates';
this.treePaths.vendor = 'vendor-addon';
},

if (name === 'vendor') {
var src = unwatchedTree(path.dirname(require.resolve('velocity-animate')));
addon = mergeTrees([addon, pickFiles(src, {srcDir: '/', destDir: 'velocity'})]);
}
treeFor: function(name) {
this._requireBuildPackages();

return addon;
};
var treePath = path.join(this.root, this.treePaths[name]);
var tree;

LiquidFire.prototype.included = function included(app) {
this.app = app;
this.app.import('vendor/velocity/jquery.velocity.js');
this.app.import('vendor/liquid-fire/liquid-fire.css');
};
if (fs.existsSync(treePath)) {
tree = this.treeGenerator(treePath);

module.exports = LiquidFire;
if(name === 'vendor') {
var velocityPath = path.dirname(require.resolve('velocity-animate'));
var velocityTree = this.pickFiles(this.treeGenerator(velocityPath), {
srcDir: '/',
destDir: 'velocity'
});

tree = this.mergeTrees([tree, velocityTree]);
}

return tree;
}
},

included: function(app) {
app.import('vendor/velocity/jquery.velocity.js');
app.import('vendor/liquid-fire/liquid-fire.css');
}
};

1 comment on commit 608e411

@jamesreggio
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is incompatible with repos on ember-cli@0.0.42, which should probably be noted in the changelog. It's worth noting that a successful build of the liquid-fire docs doesn't exercise this code—liquid-fire needs to be included as a devDependency of another project to test it. If you do (on 0.0.42), you'll receive an error about _requireBuildPackages being undefined.

It's good that this was part of a major version release, but it should probably carry a disclaimer, and the project itself should be upgraded to ember-cli@0.0.44, which isn't an entirely straightforward process. (I'm working on it, but they've changed the vendor tree yet again, which is causing some problems since we're off-reservation using a tree named other than bower_components.)

Please sign in to comment.