WORKAROUND: Add for environment variable for pandoc

This commit is contained in:
Felix Häusler 2019-10-27 17:28:34 +01:00
parent c6708e9d9a
commit cc2e9d13c0
No known key found for this signature in database
GPG Key ID: 66C2E38862BBD18A
2 changed files with 19 additions and 2 deletions

View File

@ -5,6 +5,7 @@
| `MARKTEXT_DEBUG` | Enable debug mode. | | `MARKTEXT_DEBUG` | Enable debug mode. |
| `MARKTEXT_DEBUG_KEYBOARD` | Print more keyboard information when debug mode is enabled. | | `MARKTEXT_DEBUG_KEYBOARD` | Print more keyboard information when debug mode is enabled. |
| `MARKTEXT_ERROR_INTERACTION` | Never show the error dialog to report bugs. | | `MARKTEXT_ERROR_INTERACTION` | Never show the error dialog to report bugs. |
| `MARKTEXT_PANDOC` | Overwrite the pandoc path. |
## Development ## Development

View File

@ -1,10 +1,19 @@
// Copy from https://github.com/utatti/simple-pandoc/blob/master/index.js // Copy from https://github.com/utatti/simple-pandoc/blob/master/index.js
import { spawn } from 'child_process' import { spawn } from 'child_process'
import commandExists from 'command-exists' import commandExists from 'command-exists'
import { isFile } from 'common/filesystem'
const command = 'pandoc' const pandocCommand = 'pandoc'
const getCommand = () => {
if (envPathExists()) {
return process.env.MARKTEXT_PANDOC
}
return pandocCommand
}
const pandoc = (from, to, ...args) => { const pandoc = (from, to, ...args) => {
const command = getCommand()
const option = ['-s', from, '-t', to].concat(args) const option = ['-s', from, '-t', to].concat(args)
const converter = () => new Promise((resolve, reject) => { const converter = () => new Promise((resolve, reject) => {
@ -29,7 +38,14 @@ const pandoc = (from, to, ...args) => {
} }
pandoc.exists = () => { pandoc.exists = () => {
return commandExists.sync(command) if (envPathExists()) {
return true
}
return commandExists.sync(pandocCommand)
}
const envPathExists = () => {
return !!process.env.MARKTEXT_PANDOC && isFile(process.env.MARKTEXT_PANDOC)
} }
export default pandoc export default pandoc