gabrielcsapo / node-git-server

🎡 A configurable git server written in Node.js
https://gabrielcsapo.github.io/node-git-server
MIT License
253 stars 73 forks source link

Deconstructing param causes error #19

Closed OmgImAlexis closed 6 years ago

OmgImAlexis commented 6 years ago

This works fine.

repos.on('push', push => {
    console.log(`push ${push.repo}/${push.commit} (${push.branch})`);
    push.accept();
});

This throws an error.

repos.on('push', ({repo, commit, branch, accept, cwd}) => {
    console.log(`push ${repo}/${commit} (${branch})`);
    accept();
});

The error.

➜  bree git:(master) ✗ node git.js 
node-git-server running at http://localhost:7005
push beepe/43364f2319c1de4b3b23e82895d6bf7581bae263 (master)
/Users/xo/code/bree/node_modules/node-git-server/lib/service.js:152
      if (this.status !== 'pending') return;
              ^

TypeError: Cannot read property 'status' of undefined
    at accept (/Users/xo/code/bree/node_modules/node-git-server/lib/service.js:152:15)
    at Git.repos.on (/Users/xo/code/bree/git.js:31:5)
    at emitOne (events.js:115:13)
    at Git.emit (events.js:210:7)
    at Service.action.on (/Users/xo/code/bree/node_modules/node-git-server/lib/git.js:375:22)
    at emitOne (events.js:115:13)
    at Service.emit (events.js:210:7)
    at /Users/xo/code/bree/node_modules/node-git-server/lib/service.js:86:22
    at Array.forEach (<anonymous>)
    at Stream.<anonymous> (/Users/xo/code/bree/node_modules/node-git-server/lib/service.js:65:13)
gabrielcsapo commented 6 years ago

seems like a problem with https://github.com/gabrielcsapo/node-git-server/blob/master/lib/service.js#L151 Since you are deconstructing a property from an instance of an object, the scope is removed.