2024-09-25 23:43:05 +02:00
|
|
|
import fs from "fs";
|
|
|
|
import path from "path";
|
Update data and config paths to match platform defaults (#1047)
Going forward for new installations, config and data files will be
stored at the platform default paths, as defined by
[env-paths](https://www.npmjs.com/package/env-paths).
For backwards compatibility, if the `~/.waveterm` or `WAVETERM_HOME`
directory exists and contains valid data, it will be used. If this check
fails, then `WAVETERM_DATA_HOME` and `WAVETERM_CONFIG_HOME` will be
used. If these are not defined, then `XDG_DATA_HOME` and
`XDG_CONFIG_HOME` will be used. Finally, if none of these are defined,
the [env-paths](https://www.npmjs.com/package/env-paths) defaults will
be used.
As with the existing app, dev instances will write to `waveterm-dev`
directories, while all others will write to `waveterm`.
2024-10-22 18:26:58 +02:00
|
|
|
import { getWaveConfigDir } from "./platform";
|
2024-09-25 23:43:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get settings directly from the Wave Home directory on launch.
|
|
|
|
* Only use this when the app is first starting up. Otherwise, prefer the settings.GetFullConfig function.
|
|
|
|
* @returns The initial launch settings for the application.
|
|
|
|
*/
|
|
|
|
export function getLaunchSettings(): SettingsType {
|
Update data and config paths to match platform defaults (#1047)
Going forward for new installations, config and data files will be
stored at the platform default paths, as defined by
[env-paths](https://www.npmjs.com/package/env-paths).
For backwards compatibility, if the `~/.waveterm` or `WAVETERM_HOME`
directory exists and contains valid data, it will be used. If this check
fails, then `WAVETERM_DATA_HOME` and `WAVETERM_CONFIG_HOME` will be
used. If these are not defined, then `XDG_DATA_HOME` and
`XDG_CONFIG_HOME` will be used. Finally, if none of these are defined,
the [env-paths](https://www.npmjs.com/package/env-paths) defaults will
be used.
As with the existing app, dev instances will write to `waveterm-dev`
directories, while all others will write to `waveterm`.
2024-10-22 18:26:58 +02:00
|
|
|
const settingsPath = path.join(getWaveConfigDir(), "settings.json");
|
2024-09-25 23:43:05 +02:00
|
|
|
try {
|
|
|
|
const settingsContents = fs.readFileSync(settingsPath, "utf8");
|
|
|
|
return JSON.parse(settingsContents);
|
2024-09-26 00:34:31 +02:00
|
|
|
} catch (_) {
|
|
|
|
// fail silently
|
2024-09-25 23:43:05 +02:00
|
|
|
}
|
|
|
|
}
|