Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
fix(vfiles): check for git repo before sha hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
zanona committed Nov 20, 2017
1 parent 76f77bb commit 8acb2a5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/vname.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const {stat} = require('fs'),
{exec} = require('child_process');
const {stat} = require('fs'),
{exec} = require('child_process');

function getCommitHash(filename) {
return new Promise((resolve, reject) => {
const cmd = `git log -1 --pretty=format:%h -- ${filename}`;
exec(cmd, (err, stdout) => {
if (!stdout) return reject();
resolve(stdout);
stat('.git', (statErr) => {
if (statErr) return reject(statErr);
const cmd = `git log -1 --pretty=format:%h -- ${filename}`;
exec(cmd, (gitErr, stdout) => {
if (gitErr || !stdout) return reject(gitErr);
resolve(stdout);
});
});
});
}
Expand Down

0 comments on commit 8acb2a5

Please sign in to comment.