mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-04-26 19:08:36 +00:00
fix(cli): handle incomplete localStorage in Node.js v25+
Node.js v25 provides a built-in localStorage on globalThis, but without
`--localstorage-file` it is an empty object lacking getItem/setItem.
The existing check `!("localStorage" in globalThis)` passes, so the
polyfill is skipped and the CLI crashes with:
TypeError: localStorage.getItem is not a function
Check for getItem as well so the polyfill is applied when the native
implementation is incomplete.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Command-line version of Self-hosted LiveSync plugin for syncing vaults without Obsidian
|
||||
*/
|
||||
|
||||
if (!("localStorage" in globalThis)) {
|
||||
if (!("localStorage" in globalThis) || typeof (globalThis as any).localStorage?.getItem !== "function") {
|
||||
const store = new Map<string, string>();
|
||||
(globalThis as any).localStorage = {
|
||||
getItem: (key: string) => (store.has(key) ? store.get(key)! : null),
|
||||
|
||||
Reference in New Issue
Block a user