From 9390bed45589026d31338b45488550e29b229d73 Mon Sep 17 00:00:00 2001 From: Steven Xu Date: Mon, 7 Oct 2024 01:16:23 +1100 Subject: [PATCH] feat: use XDG base directories via `app.getPath("userData")`, closes #174 --- app/pencil-core/common/config.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/pencil-core/common/config.js b/app/pencil-core/common/config.js index ca91c8c1..bb12f072 100644 --- a/app/pencil-core/common/config.js +++ b/app/pencil-core/common/config.js @@ -1,14 +1,19 @@ +const { app } = require("@electron/remote"); + var Config = { }; Config.data = {}; -Config.DATA_DIR_NAME = ".pencil"; Config.STENCILS_DIR_NAME = "stencils"; Config.PRIVATE_STENCILS_DIR_NAME = "privateCollection"; Config.CONFIG_FILE_NAME = "config.json"; Config.getDataPath = function () { - return path.join(os.homedir(), Config.DATA_DIR_NAME); + const homeDataDir = path.join(os.homedir(), ".pencil"); + if (fs.existsSync(homeDataDir)) { + return homeDataDir; + } + return app.getPath("userData"); }; Config.getDataFilePath = function (name) {