-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use correct configKey for ember-cli-babel specific options.
Newer versions of ember-cli-babel will begin deprecating passing any options in `babel` config hash that are not destined for `babel` itself (this includes `compileModules` and `includePolyfill`). This detects the newer version and uses the appropriate (non-deprecated) configuration property. It also moves `findAddonByName` into a shared utility method (to ensure both project and addon use the same mechanism).
- Loading branch information
Showing
5 changed files
with
81 additions
and
35 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
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
var find = require('ember-cli-lodash-subset').find; | ||
|
||
module.exports = function findAddonByName(addons, name) { | ||
function matchAddon(name, addon) { | ||
return name === addon.name || (addon.pkg && name === addon.pkg.name); | ||
} | ||
|
||
return find(addons, function(addon) { | ||
return matchAddon(name, addon); | ||
}); | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect; | ||
var findAddonByName = require('../../../lib/utilities/find-addon-by-name'); | ||
|
||
describe('findAddonByName', function() { | ||
var addons; | ||
beforeEach(function() { | ||
addons = [{ | ||
name: 'foo', | ||
pkg: { name: 'foo' } | ||
}, { | ||
pkg: { name: 'bar-pkg' } | ||
}, { | ||
name: 'foo-bar', | ||
pkg: { name: 'foo-bar' } | ||
}]; | ||
}); | ||
|
||
it('should return the foo addon from name', function() { | ||
var addon = findAddonByName(addons, 'foo'); | ||
expect(addon.name).to.equal('foo', 'should have found the foo addon'); | ||
}); | ||
|
||
it('should return the foo-bar addon from name when a foo also exists', function() { | ||
var addon = findAddonByName(addons, 'foo-bar'); | ||
expect(addon.name).to.equal('foo-bar', 'should have found the foo-bar addon'); | ||
}); | ||
|
||
it('should return the bar-pkg addon from package name', function() { | ||
var addon = findAddonByName(addons, 'bar-pkg'); | ||
expect(addon.pkg.name).to.equal('bar-pkg', 'should have found the bar-pkg addon'); | ||
}); | ||
|
||
it('should return undefined if addon doesn\'t exist', function() { | ||
var addon = findAddonByName(addons, 'not-an-addon'); | ||
expect(addon).to.equal(undefined, 'not found addon should be undefined'); | ||
}); | ||
|
||
it('should not return an addon that is a substring of requested name', function() { | ||
var addon = findAddonByName(addons, 'foo-ba'); | ||
expect(addon).to.equal(undefined, 'foo-ba should not be found'); | ||
}); | ||
|
||
it('should not guess addon name from string with slashes', function() { | ||
var addon = findAddonByName(addons, 'qux/foo'); | ||
expect(addon).to.equal(undefined, 'should not have found the foo addon'); | ||
}) | ||
}); |