Skip to content

Commit

Permalink
Only check semver range if ember-source is present
Browse files Browse the repository at this point in the history
Prior to this patch the value `false` would be passed to `semver.gte(`
causing an exception of `Invalid Version: false`. This ensures the range
validity of the version is only checked if one is present.

Specifically bower versions of Ember have an `emberVersion` of `false`
here. However none of those versions of Ember support co-location.

Fixes #422
  • Loading branch information
mixonic authored and rwjblue committed Jan 8, 2020
1 parent 0176e64 commit bb8a57f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/ember-addon-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ module.exports = {
let babelVersion = hasBabel && babel.pkg.version;

let ember = this.project.addons.find(a => a.name === 'ember-source');
let emberVersion = ember !== undefined && ember.pkg.version;
let hasEmberSource = ember !== undefined;
let emberVersion = hasEmberSource && ember.pkg.version;

// using this.project.emberCLIVersion() allows us to avoid issues when `npm
// link` is used; if this addon were linked and we did something like
Expand All @@ -43,7 +44,7 @@ module.exports = {

// once a polyfill is written, we will need to update this logic to check
// for _either_ `ember-source@3.13` or the polyfill
let hasValidEmberVersion = semver.gte(emberVersion, '3.13.0');
let hasValidEmberVersion = hasEmberSource && semver.gte(emberVersion, '3.13.0');

this._cachedShouldColocateTemplates =
hasValidEmberVersion && hasValidBabelVersion && hasValidEmberCLIVersion;
Expand Down

0 comments on commit bb8a57f

Please sign in to comment.