forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvPaths.js
More file actions
55 lines (43 loc) · 1.49 KB
/
envPaths.js
File metadata and controls
55 lines (43 loc) · 1.49 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import path from 'path'
class EnvPaths {
/**
* @param {string} userDataPath The user data path.
* @returns
*/
constructor (userDataPath) {
const currentDate = new Date()
if (!userDataPath) {
throw new Error('"userDataPath" is not set.')
}
this._electronUserDataPath = userDataPath // path.join(userDataPath, 'electronUserData')
this._userDataPath = userDataPath
this._logPath = path.join(this._userDataPath, 'logs', `${currentDate.getFullYear()}${currentDate.getMonth() + 1}`)
this._preferencesPath = userDataPath // path.join(this._userDataPath, 'preferences')
this._dataCenterPath = userDataPath
this._preferencesFilePath = path.join(this._preferencesPath, 'preference.json')
// TODO(sessions): enable this...
// this._globalStorage = path.join(this._userDataPath, 'globalStorage')
// this._preferencesPath = path.join(this._userDataPath, 'preferences')
// this._sessionsPath = path.join(this._userDataPath, 'sessions')
}
get electronUserDataPath () {
// This path is identical to app.getPath('userData') but userDataPath must not necessarily be the same path.
return this._electronUserDataPath
}
get userDataPath () {
return this._userDataPath
}
get logPath () {
return this._logPath
}
get preferencesPath () {
return this._preferencesPath
}
get dataCenterPath () {
return this._dataCenterPath
}
get preferencesFilePath () {
return this._preferencesFilePath
}
}
export default EnvPaths