This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Support bower.json configuration file

  • Loading branch information...
josh committed May 24, 2013
1 parent d2b3ac0 commit 5dad425ed66eeb94223c266cbd2b1a1086d8252a
View
@@ -361,6 +361,10 @@ submit a pull request.
## Version History ##
**2.10.0**
* Support for `bower.json`
**2.9.3** (April 20, 2013)
* Fixed sass caching bug
@@ -19,8 +19,10 @@ def search_paths
path_without_extensions = extensions.inject(pathname) { |p, ext| p.sub(ext, '') }
# optimization: component.json can only be nested one level deep
# optimization: bower.json can only be nested one level deep
if !path_without_extensions.to_s.index('/')
paths << path_without_extensions.join("bower.json").to_s
# DEPRECATED bower configuration file
paths << path_without_extensions.join("component.json").to_s
end
View
@@ -129,14 +129,14 @@ def resolve(logical_path, options = {})
args = attributes_for(logical_path).search_paths + [options]
@trail.find(*args) do |path|
pathname = Pathname.new(path)
if pathname.basename.to_s == 'component.json'
component = json_decode(pathname.read)
case component['main']
if %w( bower.json component.json ).include?(pathname.basename.to_s)
bower = json_decode(pathname.read)
case bower['main']
when String
yield pathname.dirname.join(component['main'])
yield pathname.dirname.join(bower['main'])
when Array
extname = File.extname(logical_path)
component['main'].each do |fn|
bower['main'].each do |fn|
if extname == "" || extname == File.extname(fn)
yield pathname.dirname.join(fn)
end
@@ -2,9 +2,9 @@
class TestAssetAttributes < Sprockets::TestCase
test "search paths" do
assert_equal ["index.js", "index/component.json"],
assert_equal ["index.js", "index/bower.json", "index/component.json"],
pathname("index.js").search_paths
assert_equal ["foo.js", "foo/component.json", "foo/index.js"],
assert_equal ["foo.js", "foo/bower.json", "foo/component.json", "foo/index.js"],
pathname("foo.js").search_paths
assert_equal ["foo/bar.js", "foo/bar/index.js"],
pathname("foo/bar.js").search_paths

0 comments on commit 5dad425

Please sign in to comment.