From 2006902b8a02ea04b7dd5803ac84237a27866b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 16 Apr 2018 16:08:30 +0200 Subject: [PATCH] Check if working directory is a git repo itself before getting commit hash --- src/helper.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/helper.js b/src/helper.js index 0f466ad2..065a83a5 100644 --- a/src/helper.js +++ b/src/helper.js @@ -62,6 +62,11 @@ function getGitCommit() { return _gitCommit; } + if (!fs.existsSync(path.resolve(__dirname, "..", ".git", "HEAD"))) { + _gitCommit = null; + return null; + } + try { _gitCommit = require("child_process") .execSync(