Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails with es6 class member functions #26

Open
psnider opened this issue Nov 28, 2016 · 0 comments
Open

fails with es6 class member functions #26

psnider opened this issue Nov 28, 2016 · 0 comments

Comments

@psnider
Copy link

psnider commented Nov 28, 2016

version 0.4.0
node v6.9.1

When I enter this code in the node REPL:

var promisify = require("promisify-node");
class C {
    constructor() {
        this.promisified_connect = promisify(this.connect);
    }
    connect(done) {
        if (done) {
            done();
        } else {
            return this.promisified_connect();
        }
    }
}
var c = new C()

promisify-node throws this error:

TypeError: Cannot read property '1' of null
    at module.exports (./node_modules/promisify-node/utils/args.js:9:63)
    at processExports (./node_modules/promisify-node/index.js:61:29)
    at module.exports (./node_modules/promisify-node/index.js:164:10)

so I updated the RegExp in https://github.com/nodegit/promisify-node/blob/master/utils/args.js#L9 from:

/function\s.*?\(([^)]*)\)/

to:

/\(([^)]*)\)/

Then re-running the above test code produced another error:

TypeError: Cannot convert undefined or null to object
    at processExports (./node_modules/promisify-node/index.js:86:16)
    at module.exports (./node_modules/promisify-node/index.js:164:10)
    at new C (repl:3:28)

I was able to get past this by modifying https://github.com/nodegit/promisify-node/blob/master/index.js#L86 to guard the checking of the keys of the prototype to:

    if (exports.prototype) {
      if (Object.keys(exports.prototype).length) {

I believe there are likely other changes required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant