Skip to content

Commit 0b8b6e1

Browse files
committed
Add static getSettingsFromConfigFile method
1 parent a32489f commit 0b8b6e1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/src/settings/ray_settings.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,24 @@ final class RaySettings {
3939
RaySettings _markAsLoadedUsingSettingsFile() {
4040
_loadedUsingSettingsFile = true;
4141
return this;
42+
static Map<String, dynamic> getSettingsFromConfigFile(
43+
[String configDirectory = '']) {
44+
final configFilePath = RaySettings.searchConfigFiles(configDirectory);
45+
46+
if (configFilePath == null) {
47+
return {};
48+
}
49+
50+
if (!File(configFilePath).existsSync()) {
51+
return {};
52+
}
53+
54+
try {
55+
final data = File(configFilePath).readAsStringSync();
56+
return jsonDecode(data);
57+
} catch (e) {
58+
rethrow;
59+
}
60+
}
4261
}
4362
}

0 commit comments

Comments
 (0)