Skip to content

Commit

Permalink
handle a number of common Git failures
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Jan 9, 2018
1 parent e964b42 commit f9105c8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,25 @@ async function getChangelogEntries(
}

export async function run(args: ReadonlyArray<string>): Promise<void> {
try {
await spawn("git", ["--version"])
} catch {
throw new Error("Unable to find Git on your PATH, aborting...")
}

try {
await spawn("git", ["rev-parse","--show-cdup"])
} catch {
throw new Error(`The current directory '${process.cwd()}' is not a Git repository, aborting...`)
}

const previousVersion = args[0];
try {
await spawn("git", ["rev-parse", previousVersion])
} catch {
throw new Error(`Unable to find ref '${previousVersion}' in your repository, aborting...`)
}

const lines = await getLogLines(previousVersion);
const changelogEntries = await getChangelogEntries(lines);
console.log(jsonStringify(changelogEntries));
Expand Down

0 comments on commit f9105c8

Please sign in to comment.