Fixing more strict null errors in build

This commit is contained in:
Matt Bierner
2018-10-02 16:54:39 -07:00
parent 6b9ec57923
commit ddc5eeee01
11 changed files with 75 additions and 51 deletions

View File

@@ -10,7 +10,7 @@ import * as fs from 'fs';
/**
* Returns the sha1 commit version of a repository or undefined in case of failure.
*/
export function getVersion(repo: string): string {
export function getVersion(repo: string): string | undefined {
const git = path.join(repo, '.git');
const headPath = path.join(git, 'HEAD');
let head: string;
@@ -50,7 +50,7 @@ export function getVersion(repo: string): string {
}
const refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm;
let refsMatch: RegExpExecArray;
let refsMatch: RegExpExecArray | null;
let refs: { [ref: string]: string } = {};
while (refsMatch = refsRegex.exec(refsRaw)) {