Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-cli-version-checker

Package Overview
Dependencies
Maintainers
5
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-version-checker - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

2

package.json
{
"name": "ember-cli-version-checker",
"version": "2.0.0",
"version": "2.1.0",
"description": "Determine if your addon is being used by a minimum version of Ember CLI.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

### Ember CLI Version Checker
# Ember CLI Version Checker

@@ -8,6 +8,33 @@ [![npm version](https://badge.fury.io/js/ember-cli-version-checker.svg)](https://badge.fury.io/js/ember-cli-version-checker)

### Usage
## Usage
#### assertAbove
Example:
You want to provide two different sets of templates, based on the currently running Ember version.
```javascript
let path = require('path');
let VersionChecker = require('ember-cli-version-checker');
module.exports = {
name: 'awesome-addon',
treeForAddonTemplates(tree) {
let checker = new VersionChecker(this);
let dep = checker.for('ember', 'bower');
let baseTemplatesPath = path.join(this.root, 'addon/templates');
if (dep.satisfies('>= 1.13.0') {
return this.treeGenerator(path.join(baseTemplatesPath, 'current'));
} else {
return this.treeGenerator(path.join(baseTemplatesPath, 'legacy'));
}
}
};
```
## API
### assertAbove
Throws an error with the given message if a minimum version isn't met.

@@ -20,3 +47,3 @@

name: 'awesome-addon',
init: function() {
init() {
this._super && this._super.init.apply(this, arguments);

@@ -38,3 +65,3 @@

name: 'awesome-addon',
init: function() {
init() {
let checker = new VersionChecker(this);

@@ -47,3 +74,3 @@

#### isAbove
### isAbove

@@ -57,3 +84,3 @@ Returns `true` if the packages version is above the specified comparison range.

name: 'awesome-addon',
init: function() {
init() {
let checker = new VersionChecker(this);

@@ -71,8 +98,10 @@ let dep = checker.for('ember-cli');

#### Real World Example
### forEmber
You want to provide two different sets of templates, based on the currently running Ember version.
Since ember introduced the `ember-source` from NPM, ember has two ways to be
shipped. One from bower `ember` and other from NPM `ember-source`. The
function `forEmber` will look for `ember-source` from NPM, if it doesn't
find it, it will look for `ember` in bower.
```javascript
let path = require('path');
let VersionChecker = require('ember-cli-version-checker');

@@ -82,13 +111,9 @@

name: 'awesome-addon',
treeForAddonTemplates: function(tree) {
init() {
let checker = new VersionChecker(this);
let dep = checker.for('ember', 'bower');
let ember = checker.forEmber();
let baseTemplatesPath = path.join(this.root, 'addon/templates');
if (dep.satisfies('>= 1.13.0') {
return this.treeGenerator(path.join(baseTemplatesPath, 'current'));
} else {
return this.treeGenerator(path.join(baseTemplatesPath, 'legacy'));
}
if (ember.isAbove('2.10.0')) {
/* deal with 2.10.0 stuff */
};
}

@@ -98,10 +123,7 @@ };

#### forEmber
### exists
Since ember introduced the `ember-source` from NPM, ember has two ways to be
shipped. One from bower `ember` and other from NPM `ember-source`. The
function `forEmber` will look for `ember-source` from NPM, if it doesn't
find it, it will look for `ember` in bower.
Returns `true` or `false` indicating if the dependency exists (at any version).
```javascript
```js
let VersionChecker = require('ember-cli-version-checker');

@@ -111,8 +133,10 @@

name: 'awesome-addon',
init: function() {
init() {
this._super.init.apply(this, arguments);
let checker = new VersionChecker(this);
let ember = checker.forEmber();
let dep = checker.for('ember-cli-qunit');
if (ember.isAbove('2.10.0')) {
/* deal with 2.10.0 stuff */
if (dep.exists()) {
/* do things when present */
};

@@ -122,1 +146,22 @@ }

```
### version
A property that returns the version for the dependency, if the dependency is not found
`undefined` will be returned.
```js
let VersionChecker = require('ember-cli-version-checker');
module.exports = {
name: 'awesome-addon',
init() {
this._super.init.apply(this, arguments);
let checker = new VersionChecker(this);
let dep = checker.for('ember-cli-qunit');
// do something with dep.version
}
};
```

@@ -39,2 +39,6 @@ 'use strict';

exists() {
return this.version !== undefined;
}
isAbove(compareVersion) {

@@ -41,0 +45,0 @@ if (!this.version) {

'use strict';
const path = require('path');
/* eslint-env node */

@@ -5,0 +5,0 @@ const BowerDependencyVersionChecker = require('./bower-dependency-version-checker');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc