-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update ember-cli addon implementation
- Loading branch information
1 parent
5aaecd3
commit 608e411
Showing
1 changed file
with
34 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
}; |
608e411
There was a problem hiding this comment.
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 theliquid-fire
docs doesn't exercise this code—liquid-fire
needs to be included as adevDependency
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 thevendor
tree yet again, which is causing some problems since we're off-reservation using a tree named other thanbower_components
.)