Skip to content

Commit

Permalink
Check if .git is a directory when printing commit hash. (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
hub2 authored and CapacitorSet committed Jun 14, 2019
1 parent b243392 commit ee71f17
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ require("./patches/prototype-plugin.js")(acorn);

lib.debug("Analysis launched: " + JSON.stringify(process.argv));
lib.verbose("Box-js version: " + require("./package.json").version);
if (fs.existsSync(path.join(__dirname, ".git"))) {

let git_path = path.join(__dirname, ".git");
if (fs.existsSync(git_path) && fs.lstatSync(git_path).isDirectory()) {
lib.verbose("Commit: " + fs.readFileSync(path.join(__dirname, ".git/refs/heads/master"), "utf8").replace(/\n/, ""));
} else {
lib.verbose("No git folder found.");
Expand Down Expand Up @@ -528,4 +530,4 @@ function hoist(obj, scope) {
hoist(obj[key], newScope);
}
}
}
}

0 comments on commit ee71f17

Please sign in to comment.