-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bufferPath to config, support bufferPath symlink (#27)
* Add bufferPath to config, support bufferPath symlink * defaultPath before checking realpath * Move code for retrieving buffer path into its own file * Do the realpathSync() call for the whole final file path, to allow the buffer file to be a symlink --------- Co-authored-by: Jonatan Heyman <[email protected]>
- Loading branch information
Showing
4 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
const os = require('os'); | ||
|
||
export const isDev = !!process.env.VITE_DEV_SERVER_URL | ||
|
||
export const isMac = os.platform() === "darwin"; | ||
export const isWindows = os.platform() === "win32"; | ||
export const isLinux = os.platform() === "linux"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import fs from "fs" | ||
import { join } from "path" | ||
import { app } from "electron" | ||
import CONFIG from "../config" | ||
import { isDev } from "../detect-platform" | ||
|
||
|
||
export function getBufferFilePath() { | ||
let defaultPath = app.getPath("userData") | ||
let configPath = CONFIG.get("settings.bufferPath") | ||
let bufferPath = configPath.length ? configPath : defaultPath | ||
let bufferFilePath = join(bufferPath, isDev ? "buffer-dev.txt" : "buffer.txt") | ||
try { | ||
// use realpathSync to resolve a potential symlink | ||
return fs.realpathSync(bufferFilePath) | ||
} catch (err) { | ||
// realpathSync will fail if the file does not exist, but that doesn't matter since the file will be created | ||
if (err.code !== "ENOENT") { | ||
throw err | ||
} | ||
return bufferFilePath | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters