Add validations

This commit is contained in:
Rodrigo Pombo 2019-02-10 17:19:11 -03:00
parent 202f85d83a
commit 456dc408e6

View File

@ -2,8 +2,22 @@
const runServer = require("./server");
const getCommits = require("./git");
const fs = require("fs");
const path = process.argv.slice(2);
const path = process.argv[2];
if (!path || path === "--help") {
console.log(`Usage:
githistory some/file.ext
`);
process.exit();
}
if (!fs.existsSync(path)) {
console.log(`File not found: ${path}`);
process.exit();
}
const commitsPromise = getCommits(path);