From 0f320f0e1ad4e21eb9800d72f171bf1a5520bd8a Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 10 Aug 2022 12:03:58 +0200 Subject: [PATCH] Do not override existing PLUGS file --- packages/server/express_server.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/server/express_server.ts b/packages/server/express_server.ts index 8615cc1..0f7d0cf 100644 --- a/packages/server/express_server.ts +++ b/packages/server/express_server.ts @@ -228,13 +228,19 @@ export class ExpressServer { ); } } - - await this.space.writePage( - "PLUGS", - "This file lists all plugs that SilverBullet will load. Run the `Plugs: Update` command to update and reload this list of plugs.\n\n```yaml\n- " + - pluginNames.map((name) => `builtin:${name}`).join("\n- ") + - "\n```" - ); + try { + await this.space.getPageMeta("PLUGS"); + console.log("PLUGS file already exists, won't override it."); + return; + } catch { + console.log("Writing fresh PLUGS file."); + await this.space.writePage( + "PLUGS", + "This file lists all plugs that SilverBullet will load. Run the `Plugs: Update` command to update and reload this list of plugs.\n\n```yaml\n- " + + pluginNames.map((name) => `builtin:${name}`).join("\n- ") + + "\n```" + ); + } } async reloadPlugs() {