diff --git a/src/extension.ts b/src/extension.ts index a72a0fc..e749fb8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -29,7 +29,17 @@ export function activate(context: vscode.ExtensionContext) { }; terminal = vscode.window.createTerminal(options); - terminal.sendText("clear; ./wait.sh"); + + const waitsh = vscode.Uri.file(path.join(getWorkingDir(), 'wait.sh')); + vscode.workspace.fs.stat(waitsh).then( + function(){ + console.log('Executing wait.sh...'); + terminal.sendText("clear; ./wait.sh"); + }, + function () { + console.log('Skipping wait, wait.sh not found.'); + } + ); context.subscriptions.push(vscode.commands.registerCommand('katapod.sendText', sendText)); context.subscriptions.push(vscode.commands.registerCommand('katapod.loadPage', loadPage)); @@ -61,15 +71,7 @@ function reloadPage(command: any) { } function loadPage (target: Target) { - lastStep = target.step; - let workingdir: string | undefined; - if (!vscode.workspace.workspaceFolders) { - workingdir = vscode.workspace.rootPath; - } else { - workingdir = vscode.workspace.workspaceFolders[0].uri.path; - } - - const file = vscode.Uri.file(path.join(workingdir, target.step + '.md')); + const file = vscode.Uri.file(path.join(getWorkingDir(), target.step + '.md')); const md = new markdownIt({html: true}) .use(require('markdown-it-textual-uml')) @@ -109,15 +111,8 @@ function loadPage (target: Target) { - - + + `; const post = ``; @@ -142,6 +137,14 @@ function renderCommandUri (command: string) { return uri; } +function getWorkingDir(): string | undefined { + if (vscode.workspace.workspaceFolders) { + return vscode.workspace.workspaceFolders[0].uri.path; + } + + return vscode.workspace.rootPath; +} + function inform (message: string) { console.log(message); vscode.window.showInformationMessage(message);