-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkspaceConfig.js
More file actions
63 lines (59 loc) · 1.59 KB
/
workspaceConfig.js
File metadata and controls
63 lines (59 loc) · 1.59 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
56
57
58
59
60
61
62
63
/* jslint esversion:11 */
const path = require("path");
const vscode = require("vscode");
function WorkspaceConfig() {
let host = "127.0.0.1";
let indexFileName;
let docsifyRootPath;
let port;
let docsifyIndexFilePath;
function init() {
port = vscode.workspace.getConfiguration("docsifyPreview").get("port");
docsifyIndexFilePath =
vscode.workspace.getConfiguration("docsifyPreview").indexFile;
docsifyRootPath = path.dirname(docsifyIndexFilePath);
indexFileName = path.basename(docsifyIndexFilePath);
}
return {
init: init,
get host() {
return host;
},
get port() {
return port;
},
async setPort(value) {
port = value;
return vscode.workspace
.getConfiguration("docsifyPreview")
.update("port", value, false);
},
get rootUrl() {
return `http://${this.host}:${this.port}/`;
},
get workspacePath() {
return vscode.workspace.workspaceFolders[0].uri.fsPath;
},
get docsifyRootPath() {
return path.join(this.workspacePath, docsifyRootPath);
},
get docsifyIndexFilePath() {
return docsifyIndexFilePath;
},
async setDocsifyIndexFilePath(newPath) {
docsifyIndexFilePath = newPath;
return vscode.workspace
.getConfiguration("docsifyPreview")
.update("indexFile", newPath, false);
},
get indexFileName() {
return indexFileName;
},
get followLinkWithCtrl() {
return vscode.workspace
.getConfiguration("docsifyPreview")
.get("followLinkWithCtrl");
},
};
}
module.exports = WorkspaceConfig();