ember-cli-version-checker
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -27,3 +27,10 @@ 'use strict'; | ||
function assertAbove(addon, minimumVersion, message) { | ||
function assertAbove(addon, minimumVersion, _message) { | ||
var message = _message; | ||
if (!message) { | ||
message = 'The addon `' + addon.name + '` requires an Ember CLI version of ' + minimumVersion + | ||
' or above, but you are running ' + getEmberCLIVersion(addon) + '.'; | ||
} | ||
if (!isAbove(addon, minimumVersion)) { | ||
@@ -30,0 +37,0 @@ var error = new Error(message); |
{ | ||
"name": "ember-cli-version-checker", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Determine if your addon is being used by a minimum version of Ember CLI.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha tests" | ||
}, | ||
@@ -9,0 +9,0 @@ "author": "Robert Jackson <me@rwjblue.com>", |
@@ -17,2 +17,15 @@ ### Ember CLI Version Checker | ||
init: function() { | ||
versionChecker.assertAbove(this, '2.0.0'); | ||
} | ||
}; | ||
``` | ||
You can also provide a specific message as the third argument to `assertAbove` if you'd like to customize the output. | ||
```javascript | ||
var versionChecker = require('ember-cli-version-checker'); | ||
module.exports = { | ||
name: 'awesome-addon', | ||
init: function() { | ||
versionChecker.assertAbove(this, '2.0.0', 'To use awesome-addon you must have ember-cli 2.0.0'); | ||
@@ -19,0 +32,0 @@ } |
@@ -6,2 +6,3 @@ var assert = require('assert'); | ||
function FakeAddonAtVersion(version) { | ||
this.name = 'fake-addon'; | ||
this.project = { | ||
@@ -59,2 +60,11 @@ emberCLIVersion: function() { | ||
describe('assertAbove', function() { | ||
it('throws an error with a default message if a matching version was not found', function() { | ||
var addon = new FakeAddonAtVersion('0.1.0'); | ||
var message = 'The addon `fake-addon` requires an Ember CLI version of 0.1.2 or above, but you are running 0.1.0.'; | ||
assert.throws(function() { | ||
versionChecker.assertAbove(addon, '0.1.2',message); | ||
}, new RegExp(message)); | ||
}); | ||
it('throws an error with the given message if a matching version was not found', function() { | ||
@@ -61,0 +71,0 @@ var addon = new FakeAddonAtVersion('0.1.0'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
5589
103
0
53