Skip to content

Commit

Permalink
Add Pandoc output channel and PR #11
Browse files Browse the repository at this point in the history
  • Loading branch information
satokaz committed Jul 9, 2016
1 parent 5bc0922 commit 37fa5db
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/extension.ts
Expand Up @@ -2,6 +2,8 @@ import * as vscode from 'vscode';
import {spawn, exec} from 'child_process';
import * as path from 'path';

var pandocOutputChannel = vscode.window.createOutputChannel('Pandoc');

function setStatusBarText(what, docType){
var date=new Date();
var text=what + ' [' + docType + '] ' + date.toLocaleTimeString();
Expand Down Expand Up @@ -45,7 +47,7 @@ export function activate(context: vscode.ExtensionContext) {
items.push({ label: 'pdf', description: 'Render as pdf document' });
items.push({ label: 'docx', description: 'Render as word document' });
items.push({ label: 'html', description: 'Render as html document' });

vscode.window.showQuickPick(items).then((qpSelection) => {
if (!qpSelection) {
return;
Expand All @@ -67,18 +69,24 @@ export function activate(context: vscode.ExtensionContext) {
var targetExec = 'pandoc' + space + inFile + space + '-o' + space + outFile + space + pandocOptions;
console.log('debug: exec ' + targetExec);

var child = exec(targetExec, function(error, stdout, stderr) {

var child = exec(targetExec, { cwd: filePath }, function(error, stdout, stderr) {
if (stdout !== null) {
console.log(stdout.toString());
pandocOutputChannel.append(stdout.toString() + '\n');
}

if (stderr !== null) {
console.log(stderr.toString());
if (stderr !== "") {
vscode.window.showErrorMessage('stderr: ' + stderr.toString());
pandocOutputChannel.append('stderr: ' + stderr.toString() + '\n');
}
}

if (error !== null) {
console.log('exec error: ' + error);
vscode.window.showErrorMessage('exec error: ' + error);
pandocOutputChannel.append('exec error: ' + error + '\n');
} else {
setStatusBarText('Launching', qpSelection.label);
switch(process.platform) {
Expand Down

0 comments on commit 37fa5db

Please sign in to comment.