pirelenito / git-revision-webpack-plugin

🏗 Webpack plugin that generates VERSION and COMMITHASH files during build
https://www.npmjs.com/package/git-revision-webpack-plugin
MIT License
358 stars 48 forks source link

error occurs without any commits #17

Closed kamataryo closed 7 years ago

kamataryo commented 7 years ago

Hello, Thanks for the cool plugin!

when I try to use with a git repository without any commits, it fails.

$ git log
fatal: your current branch 'master' does not have any commits yet
$ node
> const GitRevisionPlugin = require('git-revision-webpack-plugin')
undefined
> const gitRevisionPlugin = new GitRevisionPlugin()
undefined
> JSON.stringify(gitRevisionPlugin.version())
fatal: Not a valid object name HEAD
Error: Command failed: git describe --always
fatal: Not a valid object name HEAD

    at checkExecSyncError (child_process.js:591:13)
    at execSync (child_process.js:631:13)
    at module.exports (/Users/kamataryo/Desktop/sample/node_modules/git-revision-webpack-plugin/lib/helpers/run-git-command.js:25:34)
    at GitRevisionPlugin.version (/Users/kamataryo/Desktop/sample/node_modules/git-revision-webpack-plugin/lib/index.js:65:10)
    at repl:1:34
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:440:10)
> 
kamataryo commented 7 years ago

In the point of view of error handling, it might be related with #4.

pirelenito commented 7 years ago

Exactly! it is related to #4, but I don't have a strategy in mind yet though.

I'm going to close this and we can move the discussion to #4.