diff --git a/index.js b/index.js index c9ff1a2..fbda6c3 100644 --- a/index.js +++ b/index.js @@ -76,6 +76,19 @@ function isExpoProject(projPath) { return !!isExpoApp; } +/** + * Determines whether the project has a .git/ directory + * @param {string} projectPath Path to your project + * @return {Boolean} true if the project has a .git/ directory + */ +function isGitProject(projectPath) { + try { + return !!fs.statSync(path.join(projectPath, ".git")); + } catch (err) {} + + return false; +} + /** * Versions your app * @param {Object} program commander/CLI-style options, camelCased @@ -505,6 +518,7 @@ function version(program, projectPath) { .toString() .trim() ) && + isGitProject(projPath) && child .execSync("git describe --exact-match HEAD", gitCmdOpts) .toString() diff --git a/package.json b/package.json index effd386..3730581 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "bugs": { "url": "https://github.com/stovmascript/react-native-version/issues" }, - "version": "2.6.2", + "version": "2.6.3-0", "main": "index.js", "bin": { "react-native-version": "cli.js"