Skip to content

Commit

Permalink
Merge pull request #7 from nab911/hotfix/remove-compare-versions
Browse files Browse the repository at this point in the history
Removed compare-versions dependency.
  • Loading branch information
lteacher authored Oct 2, 2017
2 parents 87e0bc1 + 5111cd1 commit ffe920a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
22 changes: 4 additions & 18 deletions lib/handler-factory.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict'

const _ = require('lodash');
const vComp = require('compare-versions');

const requiresName = () => vComp('6.8.0', process.version.substring(1)) >= 0;

/**
* TODO: Probably refactor. Had to rewrite to native node v4 from magical v7
Expand All @@ -18,21 +15,10 @@ class HandlerFactory {
if (!_.isFunction(handler)) throw new Error('No valid handlers were provided');

if (_.isEmpty(name)) {
let msg;

if (requiresName()) {
msg = [
'Node version is <6.8.0 so named functions are required.',
'If you use anonymous functions you must use registerByName()'
].join('\n');
} else {
msg = [
'Function name is unknown. Handlers can\'t be anonymous',
'If you use anonymous functions you must use registerByName()'
].join('\n');
}

throw new Error(msg);
throw new Error(
"Function name is unknown. Handlers can\'t be anonymous\n"+
"If you use anonymous functions you must use registerByName()"
);
}
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"sinon-test": "^1.0.1"
},
"dependencies": {
"compare-versions": "^3.0.0",
"lodash": "^4.17.4"
},
"keywords": [
Expand Down
3 changes: 1 addition & 2 deletions test/lib/handler-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ describe('HandlerFactory', () => {
});

it('should throw an error when given an empty name', () => {
let vMsg = 'Node version is <6.8.0 so named functions are required.';
let nMsg = 'Function name is unknown. Handlers can\'t be anonymous';
let rMsg = 'If you use anonymous functions you must use registerByName()';

expect(() => lambda._validateHandler(undefined, console.log)).to.throw(
new RegExp(`(${vMsg}|${nMsg})\n${rMsg}`)
new RegExp(`(${nMsg})\n${rMsg}`)
);
});
});
Expand Down

0 comments on commit ffe920a

Please sign in to comment.