Skip to content

Commit eb5d30d

Browse files
committed
feat(configuration): add feature to overwrite homedir for storing models and server
1 parent cf1ea96 commit eb5d30d

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@
141141
"type": "boolean",
142142
"default": true,
143143
"markdownDescription": "Enable experimental possibility to use opened tabs as context for manual completion mode."
144+
},
145+
"firecoder.homedir": {
146+
"type": "string",
147+
"default": "",
148+
"description": "The directory to use for storing user data associated with this extension. Set to an empty string, `os.homedir()` will be used."
144149
}
145150
}
146151
}
@@ -178,4 +183,4 @@
178183
"@grafana/faro-core": "^1.3.5",
179184
"@grafana/faro-web-sdk": "^1.3.5"
180185
}
181-
}
186+
}

src/common/download/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fsPromise from "node:fs/promises";
55
import fs from "node:fs";
66
import child_process from "node:child_process";
77
import { promisify } from "node:util";
8+
import { configuration } from "../utils/configuration";
89
const exec = promisify(child_process.exec);
910

1011
export const checkFileOrFolderExists = async (pathToCheck: string) => {
@@ -17,6 +18,12 @@ export const checkFileOrFolderExists = async (pathToCheck: string) => {
1718
};
1819

1920
export const getSaveFolder = async () => {
21+
const homedirFromConfiguration = configuration.get("homedir");
22+
23+
if (homedirFromConfiguration !== "") {
24+
return homedirFromConfiguration;
25+
}
26+
2027
const pathSaveFolder = path.join(os.homedir(), ".firecoder");
2128

2229
const folderIsExist = await checkFileOrFolderExists(pathSaveFolder);

src/common/utils/configuration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const ConfigurationProperties = {
2323
"completion.manuallyMode": {
2424
default: "base-small",
2525
},
26+
homedir: {
27+
default: "",
28+
},
2629
} as const;
2730

2831
interface ConfigurationPropertiesType
@@ -48,6 +51,9 @@ interface ConfigurationPropertiesType
4851
"completion.manuallyMode": {
4952
possibleValues: TypeModelsBase;
5053
};
54+
homedir: {
55+
possibleValues: string;
56+
};
5157
}
5258

5359
class Configuration {

0 commit comments

Comments
 (0)