tvdstaaij / node-git-describe

Git describe information at runtime, with semver support
36 stars 5 forks source link

TypeError: Cannot read property 'toString' of null #8

Closed luciomartinez closed 6 years ago

luciomartinez commented 6 years ago

When on Node, trying to execute the main function it breaks without any error message.

$ node
> const { gitDescribe, gitDescribeSync } = require('git-describe');
> gitDescribe()
Promise {
  <pending>,
  domain: 
   Domain {
     domain: null,
     _events: { error: [Function: debugDomainError] },
     _eventsCount: 1,
     _maxListeners: undefined,
     members: [] } }
> (node:8132) UnhandledPromiseRejectionWarning: Error: Git returned with status ENOENT:
    at handleProcessResult (C:\Users\lucio\workspace\npl360-web-app\node_modules\git-describe\lib\git-describe.js:69:19)
    at wrapper (C:\Users\lucio\workspace\npl360-web-app\node_modules\lodash\lodash.js:5232:19)
    at exithandler (child_process.js:282:5)
    at ChildProcess.errorhandler (child_process.js:294:5)
    at emitOne (events.js:116:13)
    at ChildProcess.emit (events.js:211:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:196:12)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
(node:8132) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8132) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
> gitDescribeSync();
TypeError: Cannot read property 'toString' of null
    at handleProcessResult (C:\Users\lucio\workspace\npl360-web-app\node_modules\git-describe\lib\git-desc
ribe.js:70:20)
    at wrapper (C:\Users\lucio\workspace\npl360-web-app\node_modules\lodash\lodash.js:5232:19)
    at Object.gitDescribe (C:\Users\lucio\workspace\npl360-web-app\node_modules\git-describe\lib\git-descr
ibe.js:46:16)
    at Object.wrapper [as gitDescribeSync] (C:\Users\lucio\workspace\npl360-web-app\node_modules\lodash\lo
dash.js:5232:19)
TypeError: Cannot read property 'toString' of null
    at handleProcessResult (C:\Users\lucio\workspace\npl360-web-app\node_modules\git-describe\lib\git-desc
ribe.js:70:20)
    at wrapper (C:\Users\lucio\workspace\npl360-web-app\node_modules\lodash\lodash.js:5232:19)
    at Object.gitDescribe (C:\Users\lucio\workspace\npl360-web-app\node_modules\git-describe\lib\git-descr
ibe.js:46:16)
    at Object.wrapper [as gitDescribeSync] (C:\Users\lucio\workspace\npl360-web-app\node_modules\lodash\lo
dash.js:5232:19)

Running on Node v8.10.0 - let me know in case of more information required. Thanks!

tvdstaaij commented 6 years ago

Sorry for the slow response. I'm having a hard time reproducing this. It seems git describe is throwing an error but I can't figure out in what situation it would throw that particular error. Can one of you run this in the same working directory and as the same user:

git describe --long --dirty=-dirty --always --tags --match 'v[0-9]*'

And then post the output and status code (echo $?)?

tvdstaaij commented 6 years ago

Ah, I just realized what the problem is. This happens when the git executable does not exist or cannot be found in the system path. I will document more clearly that this module actually requires git installed and in your path, and see if I can transform the ENOENT in a better error message.