mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-08 08:23:10 +00:00
Handles the presense of previous versions of the config file
This commit is contained in:
parent
25000aa807
commit
367b889055
@ -55,6 +55,12 @@ export class ConfigService {
|
|||||||
this.saveConfig();
|
this.saveConfig();
|
||||||
} else {
|
} else {
|
||||||
this.config = this.fs.readJsonFile(filePath);
|
this.config = this.fs.readJsonFile(filePath);
|
||||||
|
|
||||||
|
if (this.config.codexRoot == undefined) {
|
||||||
|
this.config = defaultConfig;
|
||||||
|
this.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
console.error(
|
||||||
|
|||||||
@ -53,6 +53,7 @@ describe("ConfigService", () => {
|
|||||||
it("loads the config.json file when it does exist", () => {
|
it("loads the config.json file when it does exist", () => {
|
||||||
mockFsService.isFile.mockReturnValue(true);
|
mockFsService.isFile.mockReturnValue(true);
|
||||||
const savedConfig = {
|
const savedConfig = {
|
||||||
|
codexRoot: "defined",
|
||||||
isTestConfig: "Yes, very",
|
isTestConfig: "Yes, very",
|
||||||
};
|
};
|
||||||
mockFsService.readJsonFile.mockReturnValue(savedConfig);
|
mockFsService.readJsonFile.mockReturnValue(savedConfig);
|
||||||
@ -64,6 +65,22 @@ describe("ConfigService", () => {
|
|||||||
expect(mockFsService.writeJsonFile).not.toHaveBeenCalled();
|
expect(mockFsService.writeJsonFile).not.toHaveBeenCalled();
|
||||||
expect(service.config).toEqual(savedConfig);
|
expect(service.config).toEqual(savedConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("saves the default config when config.json exists but doesn't define the codexRoot", () => {
|
||||||
|
mockFsService.isFile.mockReturnValue(true);
|
||||||
|
const savedConfig = {
|
||||||
|
codexRoot: undefined, // it still blows my mind we have a language in which we can define things to be undefined.
|
||||||
|
isTestConfig: "Yes, very",
|
||||||
|
};
|
||||||
|
mockFsService.readJsonFile.mockReturnValue(savedConfig);
|
||||||
|
|
||||||
|
const service = new ConfigService(mockFsService, mockOsService);
|
||||||
|
|
||||||
|
expect(mockFsService.isFile).toHaveBeenCalledWith(configPath);
|
||||||
|
expect(mockFsService.readJsonFile).toHaveBeenCalledWith(configPath);
|
||||||
|
expect(mockFsService.writeJsonFile).toHaveBeenCalled();
|
||||||
|
expect(service.config).toEqual(expectedDefaultConfig);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getCodexExe", () => {
|
describe("getCodexExe", () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user