Skip to content

Commit

Permalink
Throw an error when using an incompatible version of Feathers (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Aug 21, 2018
1 parent adebe75 commit 546d582
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/primus/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module.exports = function (config, configurer) {
const app = this;
const getParams = spark => spark.request.feathers;

if (!app.version || app.version < '3.0.0') {
throw new Error('@feathersjs/primus is not compatible with this version of Feathers. Use the latest at @feathersjs/feathers.');
}

const done = new Promise(resolve => {
Proto.mixin({
listen (...args) {
Expand Down
21 changes: 21 additions & 0 deletions packages/primus/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/primus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@feathersjs/commons": "^1.0.0",
"@feathersjs/express": "^1.0.0-pre.3",
"@feathersjs/feathers": "^3.0.0-pre.3",
"feathers": "^2.2.3",
"feathers-memory": "^1.0.0",
"istanbul": "^1.1.0-alpha.1",
"lodash": "^4.0.1",
Expand Down
11 changes: 11 additions & 0 deletions packages/primus/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ describe('@feathersjs/primus', () => {
assert.equal(typeof require('../lib'), 'function');
});

it('throws an error when using an incompatible version of Feathers', () => {
const oldFeathers = require('feathers');

try {
oldFeathers().configure(primus());
assert.ok(false, 'Should never get here');
} catch (e) {
assert.equal(e.message, '@feathersjs/primus is not compatible with this version of Feathers. Use the latest at @feathersjs/feathers.');
}
});

it('runs primus before setup (#131)', done => {
let counter = 0;
const app = feathers()
Expand Down

0 comments on commit 546d582

Please sign in to comment.