forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.js
More file actions
36 lines (30 loc) · 1.01 KB
/
paths.js
File metadata and controls
36 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { rgPath } from 'vscode-ripgrep'
import EnvPaths from 'common/envPaths'
// // "vscode-ripgrep" is unpacked out of asar because of the binary.
const rgDiskPath = rgPath.replace(/\bapp\.asar\b/, 'app.asar.unpacked')
class RendererPaths extends EnvPaths {
/**
* Configure and sets all application paths.
*
* @param {string} userDataPath The user data path.
*/
constructor (userDataPath) {
if (!userDataPath) {
throw new Error('No user data path is given.')
}
// Initialize environment paths
super(userDataPath)
// Allow to use a local ripgrep binary (e.g. an optimized version).
if (process.env.MARKTEXT_RIPGREP_PATH) {
// NOTE: Binary must be a compatible version, otherwise the searcher may fail.
this._ripgrepBinaryPath = process.env.MARKTEXT_RIPGREP_PATH
} else {
this._ripgrepBinaryPath = rgDiskPath
}
}
// Returns the path to ripgrep on disk.
get ripgrepBinaryPath () {
return this._ripgrepBinaryPath
}
}
export default RendererPaths