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
35 lines (30 loc) · 992 Bytes
/
paths.js
File metadata and controls
35 lines (30 loc) · 992 Bytes
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
import { app } from 'electron'
import EnvPaths from 'common/envPaths'
import { ensureDirSync } from 'common/filesystem'
class AppPaths extends EnvPaths {
/**
* Configure and sets all application paths.
*
* @param {[string]} userDataPath The user data path or null.
*/
constructor (userDataPath = '') {
if (!userDataPath) {
// Use default user data path.
userDataPath = app.getPath('userData')
}
// Initialize environment paths
super(userDataPath)
// Changing the user data directory is only allowed during application bootstrap.
app.setPath('userData', this._electronUserDataPath)
}
}
export const ensureAppDirectoriesSync = paths => {
ensureDirSync(paths.userDataPath)
ensureDirSync(paths.logPath)
// TODO(sessions): enable this...
// ensureDirSync(paths.electronUserDataPath)
// ensureDirSync(paths.globalStorage)
// ensureDirSync(paths.preferencesPath)
// ensureDirSync(paths.sessionsPath)
}
export default AppPaths