import fs from 'fs' ; import path from 'path' ; import simpleGit from 'simple-git' ; const gitDir = path . resolve ( __dirname , '..' , '..' ) ; export async function gitInfo ( ) { if ( ! fs . existsSync ( path . join ( gitDir , '.git' ) ) ) { return { number : 1 , sha : process . env . GIT_COMMIT || process . env . BUILDKITE_COMMIT || 'none' , } ; } const git = simpleGit ( gitDir ) ; return new Promise < { number : number ; sha : string ; } > ( ( resolve , reject ) => { git . log ( ( err , log ) => { if ( err ) { reject ( err ) ; } else { resolve ( { number : log . total , sha : log . latest . hash , } ) ; } } ) ; } ) ; }