Created
August 26, 2021 12:42
-
-
Save BartzLeon/5e5f8fae907860b94033ac5d0affbfe2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const spawn = require('child_process').spawn; | |
const pandocPath = process.env.PANDOC || 'pandoc'; | |
let args = ['-f', from, '-t', to, '-o', 'output/' + outputFile, inputFile]; | |
let pandoc = spawn(pandocPath, args); | |
let error = ''; | |
pandoc.on('error', (err) => (throw new Error(err))); | |
pandoc.stderr.on('data', (data) => error += data); | |
pandoc.on('close', (code) => { | |
if (code !== 0) { | |
let msg = 'Pandoc finished with exit code ' + code; | |
if (error) { | |
msg += ':' + error; | |
} | |
reject(msg); | |
} else { | |
console.log('Pandoc finished successfully'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment