mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 00:01:19 +08:00
37 lines
943 B
JavaScript
37 lines
943 B
JavaScript
import path from 'path'
|
|
|
|
const additionalPaths = ({
|
|
'win32': [],
|
|
'linux': [
|
|
'/usr/bin'
|
|
],
|
|
'darwin': [
|
|
'/usr/local/bin',
|
|
'/Library/TeX/texbin'
|
|
]
|
|
})[process.platform] || []
|
|
|
|
export const checkSystem = () => {
|
|
if (additionalPaths.length > 0) {
|
|
// First integrate the additional paths that we need.
|
|
const nPATH = process.env.PATH.split(path.delimiter)
|
|
|
|
for (const x of additionalPaths) {
|
|
// Check for both trailing and non-trailing slashes (to not add any
|
|
// directory more than once)
|
|
const y = (x[x.length - 1] === '/') ? x.substr(0, x.length - 1) : x + '/'
|
|
if (!nPATH.includes(x) && !nPATH.includes(y)) {
|
|
nPATH.push(x)
|
|
}
|
|
}
|
|
|
|
process.env.PATH = nPATH.join(path.delimiter)
|
|
}
|
|
|
|
if (path.dirname('pandoc').length > 0) {
|
|
if (process.env.PATH.indexOf(path.dirname('pandoc')) === -1) {
|
|
process.env.PATH += path.delimiter + path.dirname('pandoc')
|
|
}
|
|
}
|
|
}
|