Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(prettier): fix code style
Panagiotis Papadopoulos5373ef509bda
diff --git a/src/services/data_dir.ts b/src/services/data_dir.tsindex 9b8c70ec6c..2e0c2f522e 100644--- a/src/services/data_dir.ts+++ b/src/services/data_dir.ts@@ -10,60 +10,53 @@import os from "os";import fs from "fs";-import { join as pathJoin} from "path";+import { join as pathJoin } from "path";const DIR_NAME = "trilium-data";const FOLDER_PERMISSIONS = 0o700;export function getTriliumDataDir(dataDirName: string) {- // case A- if (process.env.TRILIUM_DATA_DIR) {- createDirIfNotExisting(process.env.TRILIUM_DATA_DIR);- return process.env.TRILIUM_DATA_DIR;- }-- // case B- const homePath = pathJoin(os.homedir(), dataDirName);- if (fs.existsSync(homePath)) {- return homePath;- }-- // case C- const platformAppDataDir = getPlatformAppDataDir(os.platform(), process.env.APPDATA);- if (platformAppDataDir && fs.existsSync(platformAppDataDir)) {- const appDataDirPath = pathJoin(platformAppDataDir, dataDirName);- createDirIfNotExisting(appDataDirPath);- return appDataDirPath;- }-- // case D- createDirIfNotExisting(homePath);- return homePath;+ // case A+ if (process.env.TRILIUM_DATA_DIR) {+ createDirIfNotExisting(process.env.TRILIUM_DATA_DIR);+ return process.env.TRILIUM_DATA_DIR;+ }++ // case B+ const homePath = pathJoin(os.homedir(), dataDirName);+ if (fs.existsSync(homePath)) {+ return homePath;+ }++ // case C+ const platformAppDataDir = getPlatformAppDataDir(os.platform(), process.env.APPDATA);+ if (platformAppDataDir && fs.existsSync(platformAppDataDir)) {+ const appDataDirPath = pathJoin(platformAppDataDir, dataDirName);+ createDirIfNotExisting(appDataDirPath);+ return appDataDirPath;+ }++ // case D+ createDirIfNotExisting(homePath);+ return homePath;}export function getDataDirs(TRILIUM_DATA_DIR: string) {- const dataDirs = {- "TRILIUM_DATA_DIR":- TRILIUM_DATA_DIR,- "DOCUMENT_PATH":- process.env.TRILIUM_DOCUMENT_PATH || pathJoin(TRILIUM_DATA_DIR, "document.db"),- "BACKUP_DIR":- process.env.TRILIUM_BACKUP_DIR || pathJoin(TRILIUM_DATA_DIR, "backup"),- "LOG_DIR":- process.env.TRILIUM_LOG_DIR || pathJoin(TRILIUM_DATA_DIR, "log"),- "ANONYMIZED_DB_DIR":- process.env.TRILIUM_ANONYMIZED_DB_DIR || pathJoin(TRILIUM_DATA_DIR, "anonymized-db"),- "CONFIG_INI_PATH":- process.env.TRILIUM_CONFIG_INI_PATH || pathJoin(TRILIUM_DATA_DIR, "config.ini")- } as const-- Object.freeze(dataDirs);- return dataDirs;+ const dataDirs = {+ TRILIUM_DATA_DIR: TRILIUM_DATA_DIR,+ DOCUMENT_PATH: process.env.TRILIUM_DOCUMENT_PATH || pathJoin(TRILIUM_DATA_DIR, "document.db"),+ BACKUP_DIR: process.env.TRILIUM_BACKUP_DIR || pathJoin(TRILIUM_DATA_DIR, "backup"),+ LOG_DIR: process.env.TRILIUM_LOG_DIR || pathJoin(TRILIUM_DATA_DIR, "log"),+ ANONYMIZED_DB_DIR: process.env.TRILIUM_ANONYMIZED_DB_DIR || pathJoin(TRILIUM_DATA_DIR, "anonymized-db"),+ CONFIG_INI_PATH: process.env.TRILIUM_CONFIG_INI_PATH || pathJoin(TRILIUM_DATA_DIR, "config.ini")+ } as const;++ Object.freeze(dataDirs);+ return dataDirs;}export function getPlatformAppDataDir(platform: ReturnType<typeof os.platform>, ENV_APPDATA_DIR: string | undefined = process.env.APPDATA) {-- switch(true) {+ switch (true) {case platform === "win32" && !!ENV_APPDATA_DIR:return ENV_APPDATA_DIR;@@ -77,7 +70,6 @@ export function getPlatformAppDataDir(platform: ReturnType<typeof os.platform>,// if OS is not recognizedreturn null;}-}function createDirIfNotExisting(path: fs.PathLike, permissionMode: fs.Mode = FOLDER_PERMISSIONS) {@@ -86,9 +78,7 @@ function createDirIfNotExisting(path: fs.PathLike, permissionMode: fs.Mode = FOL}}--const TRILIUM_DATA_DIR = getTriliumDataDir(DIR_NAME);const dataDirs = getDataDirs(TRILIUM_DATA_DIR);-export default dataDirs;\ No newline at end of file+export default dataDirs;