Brakes doesn't work with service calls that are arrow functions
awolden opened this issue · comments
const Brakes = require('brakes');
const prom = (foo) => {
return new Promise((resolve, reject) => {
resolve(foo);
});
}
const brake = new Brakes(prom);
brake.exec('foo').then(result => {
console.log(result)
}, err => {
console.error(err);
});
Causes the following error:
./node_modules/brakes/node_modules/promisify-node/utils/args.js:9
var args = func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
^
TypeError: Cannot read property '1' of null
at module.exports (./node_modules/brakes/node_modules/promisify-node/utils/args.js:9:63)
at processExports (./node_modules/brakes/node_modules/promisify-node/index.js:61:29)
at module.exports (./node_modules/brakes/node_modules/promisify-node/index.js:164:10)
at new Brakes (./node_modules/brakes/lib/Brakes.js:32:25)
at Object.<anonymous> (./index.js:10:15)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
This seems to be caused by reflection that promisify-node is doing under the covers to detect meta data about the passed in function.
Created a ticket with promisify-node
here: nodegit/promisify-node#18
Pull request to fix issue here: nodegit/promisify-node#19
fixed in release 1.1.0