Skip to content

Commit

Permalink
Refs #6 Fix "console.error is not a function" on newer versions of node
Browse files Browse the repository at this point in the history
  • Loading branch information
onebytegone committed Dec 14, 2018
1 parent 1c1b892 commit ff593d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions _makeLambdaHandler.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
'use strict';

var Q = require('q');
var Q = require('q'),
log = console.log.bind(console); // eslint-disable-line no-console

Q.longStackSupport = true;

module.exports = function(returnResolvedValue) {
return function(promiseReturningHandlerFn, context, cb) {
Q.promised(promiseReturningHandlerFn)()
.then(function(v) {
// eslint-disable-next-line no-console
console.log('completed with %s millis left', context.getRemainingTimeInMillis());
log('completed with %s millis left', context.getRemainingTimeInMillis());
if (returnResolvedValue) {
return cb(undefined, v);
}
return cb();
})
.catch(function(err) {
// eslint-disable-next-line no-console
console.log('ERROR:', err, err.stack);
log('ERROR:', err, err.stack);
cb(err);
})
.done();
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _.each([ true, false ], function(returns) {

beforeEach(function() {
revert = makeHandler.__set__({
console: { log: _.noop },
log: _.noop,
});
});

Expand Down

0 comments on commit ff593d5

Please sign in to comment.