Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit abd30ee

Browse files
committed
Dont error if file is missing
1 parent 2e91985 commit abd30ee

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

src/SettingsManager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "fs";
22
import os from "os";
33
import path from "path";
4+
import { KmdrError } from "./errors";
45
import { Settings, SettingsFile, Theme } from "./interfaces";
56
import ThemeManager from "./ThemeManager";
67

@@ -48,7 +49,7 @@ export default class SettingsManager implements Settings {
4849

4950
this.loadAllThemes();
5051
// If directory does not exists, use default settings
51-
if (!fs.existsSync(this.settingsPath)) {
52+
if (!fs.existsSync(path.join(this.settingsPath, "settings.json"))) {
5253
this.loadDefault();
5354
} else {
5455
this.loadFromDisk();
@@ -104,6 +105,10 @@ export default class SettingsManager implements Settings {
104105
} else {
105106
const parsedFile = JSON.parse(file) as SettingsFile;
106107

108+
if (parsedFile.theme.trim() === "") {
109+
throw new KmdrError("KMDR_CLI_INVALID_THEME_NAME", 201, `Settings file is invalid`);
110+
}
111+
107112
this.theme = this.loadTheme(parsedFile.theme) || new ThemeManager(DEFAULT_THEME);
108113
}
109114
} catch (err) {

src/files/themes/dia.theme.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
"palette": {
55
"argument": {
66
"bold": true,
7-
"foreground": "#f8f8f2",
7+
"foreground": "#575F66",
88
"italic": true
99
},
1010
"comment": {
11-
"foreground": "#6272a4"
11+
"foreground": "#ABB0B6"
12+
},
13+
"function": {
14+
"foreground": "#F2AE49"
1215
},
1316
"keyword": {
1417
"foreground": "#ff5555"
@@ -17,17 +20,23 @@
1720
"foreground": "#f1fa8c"
1821
},
1922
"option": {
20-
"foreground": "#50fa7b"
23+
"foreground": "#399EE6",
24+
"bold": true
2125
},
2226
"program": {
23-
"foreground": "#224466"
27+
"foreground": "#F2AE49",
28+
"bold": true
2429
},
2530
"subcommand": {
26-
"foreground": "#bd93f9"
31+
"foreground": "#4CBF99",
32+
"bold": true
33+
},
34+
"varName": {
35+
"foreground": "#F07171",
36+
"bold": true
2737
},
2838
"tokenKind": {
2939
"background": "#222222",
30-
3140
"foreground": "#AA5599"
3241
}
3342
}

src/files/themes/greenway.theme.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
"foreground": "#f1fa8c"
1818
},
1919
"option": {
20-
"foreground": "#50fa7b"
20+
"foreground": "#50fa7b",
21+
"bold": true
2122
},
2223
"program": {
23-
"foreground": "#FFC0CB"
24+
"foreground": "#FFC0CB",
25+
"bold": true
2426
},
2527
"subcommand": {
26-
"foreground": "#bd93f9"
28+
"foreground": "#bd93f9",
29+
"bold": true
2730
},
2831
"tokenKind": {
2932
"background": "#222222",

0 commit comments

Comments
 (0)