@@ -75,18 +75,29 @@ interface CzConfig {
7575
7676let gitRoot : string | undefined = undefined ;
7777async function findLookupPath ( ) : Promise < string | undefined > {
78+ let ws = '' ;
79+ if ( ! vscode . workspace . workspaceFolders ) {
80+ return undefined ;
81+ } else {
82+ ws = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
83+ }
84+
7885 if ( getConfiguration ( ) . useGitRoot && gitRoot === undefined ) {
7986 gitRoot = await new Promise < string > ( ( resolve , reject ) =>
80- exec ( 'git rev-parse --show-toplevel' , ( err , stdout , stderr ) => {
81- if ( err ) {
82- reject ( { err, stderr } ) ;
83- } else if ( stdout ) {
84- channel . appendLine ( `Found git root at: ${ stdout } ` ) ;
85- resolve ( stdout . trim ( ) ) ;
86- } else {
87- reject ( { err : 'Unable to find git root' } ) ;
87+ exec (
88+ 'git rev-parse --show-toplevel' ,
89+ { cwd : ws } ,
90+ ( err , stdout , stderr ) => {
91+ if ( err ) {
92+ reject ( { err, stderr } ) ;
93+ } else if ( stdout ) {
94+ channel . appendLine ( `Found git root at: ${ stdout } ` ) ;
95+ resolve ( stdout . trim ( ) ) ;
96+ } else {
97+ reject ( { err : 'Unable to find git root' } ) ;
98+ }
8899 }
89- } )
100+ )
90101 ) . catch ( ( e ) => {
91102 channel . appendLine ( e . err . toString ( ) ) ;
92103 if ( e . stderr ) {
@@ -98,10 +109,8 @@ async function findLookupPath(): Promise<string | undefined> {
98109
99110 if ( gitRoot ) {
100111 return gitRoot ;
101- } else if ( ! vscode . workspace . workspaceFolders ) {
102- return undefined ;
103112 } else {
104- return vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
113+ return ws ;
105114 }
106115}
107116
0 commit comments