Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export interface LatexOptions {
* to.
*/
errorLogs?: string

/**
* The path to where the user wants to save the AUX and LOG files to.
*/
auxiliary?: string
}

/**
Expand Down
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,23 @@ function latex(src, options) {
// The path(s) to your precompiled files.
const precompiled = options.precompiled ? resolvePaths(options.precompiled) : null

// The path to where the user wants to save the AUX and LOG files to.
const auxiliaryPath = options.auxiliary

const copyPrecompiled = (pathToPrecompiled) => {
fs.readdirSync(pathToPrecompiled).forEach(file =>
fs.copyFileSync(path.resolve(pathToPrecompiled, file), path.resolve(tempPath, file))
)
}

const copyAuxiliaryFiles = (pathToAuxiliaryFiles) => {
fs.readdirSync(tempPath).forEach(file => {
if (file.endsWith('.aux') || file.endsWith('.log')) {
fs.copyFileSync(path.resolve(tempPath, file), path.resolve(pathToAuxiliaryFiles, file))
}
})
}

// The current amount of times LaTeX has run so far.
let completedPasses = 0

Expand Down Expand Up @@ -200,6 +211,11 @@ function latex(src, options) {
const pdfStream = fs.createReadStream(pdfPath)

pdfStream.pipe(outputStream)

if (auxiliaryPath) {
copyAuxiliaryFiles(auxiliaryPath)
}

pdfStream.on('close', () => fse.removeSync(tempPath))
pdfStream.on('error', handleErrors)
}
Expand Down
Loading