@@ -5,7 +5,7 @@ import { exec } from "./shell";
55/**
66 * Gets the current working branch.
77 */
8- export const getCurrentBranch = async ( ) => {
8+ export const getCurrentBranch = async ( ) : Promise < string > => {
99 try {
1010 const branch = await exec ( "git" , [ "rev-parse" , "--abbrev-ref" , "HEAD" ] ) ;
1111 return branch ;
@@ -23,15 +23,15 @@ export const getCurrentBranch = async () => {
2323export const checkoutBranch = async (
2424 branchName : string ,
2525 createNewBranch : boolean
26- ) => {
26+ ) : Promise < void > => {
2727 try {
2828 if ( createNewBranch ) {
2929 await exec ( "git" , [ "checkout" , "-b" , `${ branchName } ` ] ) ;
3030 } else {
3131 await exec ( "git" , [ "checkout" , `${ branchName } ` ] ) ;
3232 }
3333 } catch ( _ ) {
34- throw new Error ( `Unable to checkout git branch ${ branchName } : ` + _ ) ;
34+ throw Error ( `Unable to checkout git branch ${ branchName } : ` + _ ) ;
3535 }
3636} ;
3737
@@ -40,11 +40,11 @@ export const checkoutBranch = async (
4040 *
4141 * @param branchName
4242 */
43- export const deleteBranch = async ( branchName : string ) => {
43+ export const deleteBranch = async ( branchName : string ) : Promise < void > => {
4444 try {
4545 await exec ( "git" , [ "branch" , "-D" , `${ branchName } ` ] ) ;
4646 } catch ( _ ) {
47- throw new Error ( `Unable to delete git branch ${ branchName } : ` + _ ) ;
47+ throw Error ( `Unable to delete git branch ${ branchName } : ` + _ ) ;
4848 }
4949} ;
5050
@@ -54,12 +54,15 @@ export const deleteBranch = async (branchName: string) => {
5454 * @param directory
5555 * @param branchName
5656 */
57- export const commitDir = async ( directory : string , branchName : string ) => {
57+ export const commitDir = async (
58+ directory : string ,
59+ branchName : string
60+ ) : Promise < void > => {
5861 try {
5962 await exec ( "git" , [ "add" , `${ directory } ` ] ) ;
6063 await exec ( "git" , [ "commit" , "-m" , `Adding new service: ${ branchName } ` ] ) ;
6164 } catch ( _ ) {
62- throw new Error (
65+ throw Error (
6366 `Unable to commit changes in ${ directory } to git branch ${ branchName } : ` +
6467 _
6568 ) ;
@@ -71,18 +74,18 @@ export const commitDir = async (directory: string, branchName: string) => {
7174 *
7275 * @param branchName
7376 */
74- export const pushBranch = async ( branchName : string ) => {
77+ export const pushBranch = async ( branchName : string ) : Promise < void > => {
7578 try {
7679 await exec ( "git" , [ "push" , "-u" , "origin" , `${ branchName } ` ] ) ;
7780 } catch ( _ ) {
78- throw new Error ( `Unable to push git branch ${ branchName } : ` + _ ) ;
81+ throw Error ( `Unable to push git branch ${ branchName } : ` + _ ) ;
7982 }
8083} ;
8184
8285/**
8386 * Gets the origin url.
8487 */
85- export const getOriginUrl = async ( ) => {
88+ export const getOriginUrl = async ( ) : Promise < string > => {
8689 try {
8790 const originUrl = await exec ( "git" , [
8891 "config" ,
@@ -92,9 +95,8 @@ export const getOriginUrl = async () => {
9295 logger . debug ( `Got git origin url ${ originUrl } ` ) ;
9396 return originUrl ;
9497 } catch ( _ ) {
95- throw new Error ( `Unable to get git origin URL.: ` + _ ) ;
98+ throw Error ( `Unable to get git origin URL.: ` + _ ) ;
9699 }
97- return "" ;
98100} ;
99101
100102/**
@@ -109,7 +111,7 @@ export const getPullRequestLink = async (
109111 baseBranch : string ,
110112 newBranch : string ,
111113 originUrl : string
112- ) => {
114+ ) : Promise < string > => {
113115 try {
114116 const gitComponents = GitUrlParse ( originUrl ) ;
115117 if ( gitComponents . resource . includes ( "dev.azure.com" ) ) {
@@ -125,7 +127,7 @@ export const getPullRequestLink = async (
125127 return "Could not determine origin repository, or it is not a supported provider. Please check for the newly pushed branch and open a PR manually." ;
126128 }
127129 } catch ( _ ) {
128- throw new Error (
130+ throw Error (
129131 `"Could not determine git provider, or it is not a supported type.": ` + _
130132 ) ;
131133 }
@@ -134,7 +136,7 @@ export const getPullRequestLink = async (
134136export const checkoutCommitPushCreatePRLink = async (
135137 newBranchName : string ,
136138 directory : string
137- ) => {
139+ ) : Promise < void > => {
138140 try {
139141 const currentBranch = await getCurrentBranch ( ) ;
140142 try {
0 commit comments