From 60c82062f44a6327934a50e9dc391be0a4957780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCller?= Date: Thu, 12 Apr 2018 07:22:43 +0200 Subject: [PATCH] Set working directory when calling latex binaries --- src/components/linter.ts | 2 +- src/components/locator.ts | 4 ++-- src/providers/latexformatter.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/linter.ts b/src/components/linter.ts index befcffeed..3905b70aa 100644 --- a/src/components/linter.ts +++ b/src/components/linter.ts @@ -64,7 +64,7 @@ export class Linter { let stdout: string try { - stdout = await this.processWrapper('active file', command, args.concat(requiredArgs).filter(arg => arg !== ''), {}, content) + stdout = await this.processWrapper('active file', command, args.concat(requiredArgs).filter(arg => arg !== ''), {cwd: path.dirname(filePath)}, content) } catch (err) { if ('stdout' in err) { stdout = err.stdout diff --git a/src/components/locator.ts b/src/components/locator.ts index f087a500a..e1ee5788d 100644 --- a/src/components/locator.ts +++ b/src/components/locator.ts @@ -77,7 +77,7 @@ export class Locator { const args = ['view', '-i', `${line}:${position.character + 1}:${filePath}`, '-o', pdfFile] this.extension.logger.addLogMessage(`Executing synctex with args ${args}`) - const proc = cp.spawn(configuration.get('synctex.path') as string, args) + const proc = cp.spawn(configuration.get('synctex.path') as string, args, {cwd: path.dirname(pdfFile)}) proc.stdout.setEncoding('utf8') proc.stderr.setEncoding('utf8') @@ -109,7 +109,7 @@ export class Locator { const args = ['edit', '-o', `${data.page}:${data.pos[0]}:${data.pos[1]}:${pdfPath}`] this.extension.logger.addLogMessage(`Executing synctex with args ${args}`) - const proc = cp.spawn(configuration.get('synctex.path') as string, args) + const proc = cp.spawn(configuration.get('synctex.path') as string, args, {cwd: path.dirname(pdfPath)}) proc.stdout.setEncoding('utf8') proc.stderr.setEncoding('utf8') diff --git a/src/providers/latexformatter.ts b/src/providers/latexformatter.ts index 55df86edc..33a07736f 100644 --- a/src/providers/latexformatter.ts +++ b/src/providers/latexformatter.ts @@ -125,7 +125,7 @@ export class LaTexFormatter { .replace('%TMPFILE%', temporaryFile.split(path.sep).join('/')) .replace('%INDENT%', indent)) - const worker = cp.spawn(this.formatter, args, { stdio: 'pipe' }) + const worker = cp.spawn(this.formatter, args, { stdio: 'pipe', cwd: path.dirname(document.fileName) }) // handle stdout/stderr const stdoutBuffer = [] as string[] const stderrBuffer = [] as string[]