@@ -17,7 +17,7 @@ class TaskfileService {
1717 public async read ( ) : Promise < models . Taskfile > {
1818 return await new Promise ( ( resolve , reject ) => {
1919 let command = 'task --list-all --json' ;
20- cp . exec ( command , ( err : cp . ExecException | null , stdout : string , stderr : string ) => {
20+ cp . exec ( command , { cwd : getWorkspaceFolder ( ) } , ( err : cp . ExecException | null , stdout : string , stderr : string ) => {
2121 if ( err ) {
2222 console . log ( 'error: ' + err ) ;
2323 reject ( ) ;
@@ -32,7 +32,7 @@ class TaskfileService {
3232 public async runTask ( taskName : string ) : Promise < void > {
3333 return await new Promise ( ( resolve , reject ) => {
3434 let command = `task ${ taskName } ` ;
35- cp . exec ( command , ( err : cp . ExecException | null , stdout : string , stderr : string ) => {
35+ cp . exec ( command , { cwd : getWorkspaceFolder ( ) } , ( err : cp . ExecException | null , stdout : string , stderr : string ) => {
3636 if ( err ) {
3737 console . log ( 'error: ' + err ) ;
3838 reject ( ) ;
@@ -48,3 +48,10 @@ class TaskfileService {
4848}
4949
5050export const taskfile = TaskfileService . Instance ;
51+
52+ function getWorkspaceFolder ( ) : string | undefined {
53+ if ( ! vscode . workspace . workspaceFolders || vscode . workspace . workspaceFolders . length === 0 ) {
54+ return undefined ;
55+ }
56+ return vscode . workspace . workspaceFolders [ 0 ] . uri . path ;
57+ }
0 commit comments