From 2ef3d5eb016de562a89b66a73c18be60377d0a97 Mon Sep 17 00:00:00 2001 From: PJ Date: Tue, 25 May 2021 12:40:44 -0400 Subject: [PATCH] Support symlinked plugins on Windows and OSX --- main.js | 8 +++++--- manifest.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index b410056..53e4fc7 100644 --- a/main.js +++ b/main.js @@ -17,13 +17,15 @@ module.exports = class HotReload extends Plugin { } watch(path) { - if (!watchNeeded) return; if (this.app.vault.adapter.watchers.hasOwnProperty(path)) return; - if (fs.existsSync(path) && fs.statSync(path).isDirectory()) this.app.vault.adapter.startWatchPath(path, false); + const realPath = [this.app.vault.adapter.basePath, path].join("/"); + const lstat = fs.lstatSync(realPath); + if (lstat && (watchNeeded || lstat.isSymbolicLink()) && fs.statSync(realPath).isDirectory()) { + this.app.vault.adapter.startWatchPath(path, false); + } } async getPluginNames() { - await this.app.plugins.loadManifests(); const plugins = {}, enabled = new Set(); for (const {id, dir} of Object.values(app.plugins.manifests)) { this.watch(dir); diff --git a/manifest.json b/manifest.json index 1d17600..676b784 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "hot-reload", "name": "Hot Reload", - "version": "0.1.7", + "version": "0.1.8", "minAppVersion": "0.11.13", "description": "Automatically reload in-development plugins when their files are changed", "isDesktopOnly": true