diff --git a/firebase-vscode/src/core/index.ts b/firebase-vscode/src/core/index.ts index 6f3e5664e48..d15ffd6f352 100644 --- a/firebase-vscode/src/core/index.ts +++ b/firebase-vscode/src/core/index.ts @@ -55,13 +55,16 @@ export async function registerCore( return; } const workspaceFolder = vscode.workspace.workspaceFolders[0]; + const initCommand = currentProjectId.value ? + `${settings.firebasePath} init dataconnect --project ${currentProjectId.value}` : + `${settings.firebasePath} init dataconnect`; vscode.tasks.executeTask( new vscode.Task( { type: "shell" }, // this is the same type as in tasks.json workspaceFolder, // The workspace folder "firebase init dataconnect", // how you name the task "firebase init dataconnect", // Shows up as MyTask: name - new vscode.ShellExecution(`${settings.firebasePath} init dataconnect --project ${currentProjectId.value}`), + new vscode.ShellExecution(initCommand), ), ); }); diff --git a/firebase-vscode/src/data-connect/terminal.ts b/firebase-vscode/src/data-connect/terminal.ts index 564e747d954..50c4e28a011 100644 --- a/firebase-vscode/src/data-connect/terminal.ts +++ b/firebase-vscode/src/data-connect/terminal.ts @@ -27,7 +27,10 @@ export function runCommand(command: string) { // TODO: This fails if the interactive shell is not expecting a command, such // as when oh-my-zsh asking for (Y/n) to updates during startup. // Consider using an non-interactive shell. - terminal.sendText(`${command} -P ${currentProjectId.value}`); + if (currentProjectId.value) { + command = `${command} --project ${currentProjectId.value}`; + } + terminal.sendText(command); } export function runTerminalTask(