extract tex cmd

to make it configurable at a later point in time
This commit is contained in:
Thomas Ruoff
2021-03-02 00:36:08 +01:00
parent 0aaccf6966
commit e601971a50
2 changed files with 15 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ import { mkdir, writeFile } from 'fs'
import { spawn } from 'child_process'
import { v1 as uuidv1 } from 'uuid'
import { getDirPath, getDocPath } from './utils'
import { getDirPath, getDocPath, getTexCmd } from './utils'
function copyToTemp(id: string, texDocument: string): Promise<string> {
return new Promise((resolve, reject) => {
@@ -26,10 +26,15 @@ function copyToTemp(id: string, texDocument: string): Promise<string> {
}
function generateDoc(id: string) {
return new Promise((resolve, reject) => {
const pdflatex = spawn('pdflatex', ['-interaction', 'nonstopmode', getDocPath(id)], { cwd: getDirPath(id) })
pdflatex.stderr.on('data', (data) => {
console.error('onData', data)
return new Promise((resolve, reject): void => {
const pdflatex = spawn(...getTexCmd(id))
pdflatex.stderr?.on('data', (data: string) => {
console.error('error: ', data)
reject()
})
pdflatex.on('error', (error) => {
console.error('error', error)
reject()
})
pdflatex.on('close', (code) => {