-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/version-checks: Use
hasEmberVersion()
function
- Loading branch information
Showing
1 changed file
with
16 additions
and
20 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,23 +1,19 @@ | ||
import Ember from 'ember'; | ||
|
||
const { VERSION } = Ember; | ||
export const hasPositionalParams = hasEmberVersion(1, 13); | ||
export const hasReliablePositionalParams = hasEmberVersion(2, 3); | ||
|
||
const EMBERS_WITHOUT_POSITIONAL_PARAMS = [ | ||
'1.12', | ||
'1.11', | ||
]; | ||
|
||
const EMBERS_WITHOUT_RELIABLE_POSITIONAL_PARAMS = [ | ||
'2.2', | ||
'2.1', | ||
'2.0', | ||
'1.13', | ||
'1.12', | ||
'1.11', | ||
]; | ||
|
||
export const hasPositionalParams = !EMBERS_WITHOUT_POSITIONAL_PARAMS | ||
.some(version => VERSION.indexOf(`${version}.`) === 0); | ||
|
||
export const hasReliablePositionalParams = !EMBERS_WITHOUT_RELIABLE_POSITIONAL_PARAMS | ||
.some(version => VERSION.indexOf(`${version}.`) === 0); | ||
/** | ||
Checks if the currently running Ember version is greater than or equal to the | ||
specified major and minor version numbers. | ||
@private | ||
@param {number} major the major version number to compare | ||
@param {number} minor the minor version number to compare | ||
@returns {boolean} true if the Ember version is >= MAJOR.MINOR specified, false otherwise | ||
*/ | ||
export function hasEmberVersion(major, minor) { | ||
var numbers = Ember.VERSION.split('-')[0].split('.'); | ||
var actualMajor = parseInt(numbers[0], 10); | ||
var actualMinor = parseInt(numbers[1], 10); | ||
return actualMajor > major || (actualMajor === major && actualMinor >= minor); | ||
} |