After compiling and running the TypeScript code below, the application named Notion will open:
const cmd = 'open -a "/Applications/Notion.app"';
exec(cmd, (error, stdout, stderr) => {});
If I try running the same code within my extension.ts
file, the command is executed but Notion does not open. Nothing happens, there's no output from the open
command in terms of stdout, stderr, or error messages. This issue also occurs with other applications.
import * as vscode from 'vscode';
import {exec} from 'child_process'
export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('helloworld.helloWorld', () => {
const cmd = 'open -a "/Applications/Notion.app"';
vscode.window.showInformationMessage(`Running command: ${cmd}`);
exec(cmd, (error, stdout, stderr) => {});
});
context.subscriptions.push(disposable);
}
export function deactivate() {}
Is there a way to successfully open an external application from within my vscode extension?