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
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChildProcess } from 'child_process'
import { Readable, Transform } from 'stream'

/**
Expand Down Expand Up @@ -39,6 +40,12 @@ export interface LatexOptions {
* to.
*/
errorLogs?: string

/**
* A function to call on each LaTeX invocation. The only argument is an instance
* of ChildProcess.
*/
spawnCallback?: (proc: ChildProcess) => void
}

/**
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ function latex(src, options) {
const runLatex = (inputStream) => {
const tex = spawn(cmd, args, opts)

if (options.spawnCallback) {
options.spawnCallback(tex);
}

inputStream.pipe(tex.stdin)

// Prevent Node from crashing on compilation error.
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ View more examples [here](https://github.com/saadq/node-latex/tree/master/exampl

**options.errorLogs** \[String] - The path to the file where you want to save the contents of the error log to.

**options.spawnCallback** \[Function] - A function to call on each LaTeX invocation. The only argument is an instance of `ChildProcess`.

## License
MIT