Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
Something went wrong. Try again.
2.4 kB · 54 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import * as path from 'path';import envPaths from 'env-paths';
const osPaths = envPaths('multi-scrobbler', {suffix: ''});
// see https://docs.multi-scrobbler.app/installation/#config-and-data-directories// for systemd see: https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#:~:text=Table%C2%A02%2E%C2%A0Automatic%20directory%20creation%20and%20environment%20variables// for os-specific like (linux) XDG, (mac) ~Library/..., (window) %APPDATA%\... or %LOCALAPPDATA%\...
export const getConfigDir = (): string => { let configDirVal: string = process.env.CONFIG_DIR // user-defined OR used by Dockerfile ?? process.env.CONFIGURATION_DIRECTORY // set by systemd ?? osPaths.config; // os-specific path
// this shouldn't happen... // but if it does we need to have some known path fallback so things don't explode if(configDirVal === undefined) { configDirVal = getPathFromCWD('./config'); // backwards compatibility } // resolve from relative directory, if one was used return path.resolve(configDirVal);}
export const getDataDir = (): string => { let dataDirVal: string = process.env.DATA_DIR ?? // user-defined OR used by Dockerfile process.env.STATE_DIRECTORY ?? // set by systemd osPaths.data; // os-specific path
// this shouldn't happen... // but if it does we need to have some known path fallback so things don't explode if(dataDirVal === undefined) { dataDirVal = getPathFromCWD('./config'); // defaulting to same directory for backwards compatibility } // resolve from relative directory, if one was used return path.resolve(dataDirVal);}
export const getLogsDir = (): string => { let dataDirVal: string = process.env.LOGS_DIR ?? // user-defined OR used by Dockerfile. For Dockerfile this is DATA_DIR/logs process.env.LOGS_DIRECTORY ?? // set by systemd osPaths.log; // os-specific path
// this shouldn't happen... // but if it does we need to have some known path fallback so things don't explode if(dataDirVal === undefined) { dataDirVal = getPathFromCWD('./config/logs'); // defaulting to same directory for backwards compatibility } // resolve from relative directory, if one was used return path.resolve(dataDirVal);}
export const getPathFromCWD = (...relativePaths: string[]) => path.resolve(process.cwd(), ...relativePaths);