From 41b28fd2eced4e7e0505f068fd4bd84b801ddde9 Mon Sep 17 00:00:00 2001 From: JupiterPi Date: Tue, 10 Dec 2024 10:48:44 +0100 Subject: [PATCH] fix: allow syncPairs.json to contain a `SyncPair` instead of `SyncPair[]` --- src/featureInterfaces/syncInterface.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/featureInterfaces/syncInterface.ts b/src/featureInterfaces/syncInterface.ts index 756de26..fbb16e1 100644 --- a/src/featureInterfaces/syncInterface.ts +++ b/src/featureInterfaces/syncInterface.ts @@ -179,8 +179,8 @@ export class SyncInterface { } const file = JSON.parse((await fsModule.promises.readFile(path)).toString()) const exitTypeErr = () => errExit("Invalid sync pairs registry! Needs to be of type: {local: string, remote: string, syncMode: string, alias?: string, excludeDotFiles?: boolean, disableLocalTrash?: boolean, ignore?: string[]}[]") - if (!Array.isArray(file)) exitTypeErr() - for (const obj of file) { + const syncPairsObj = Array.isArray(file) ? file : [file] + for (const obj of syncPairsObj) { if (typeof obj.local !== "string") exitTypeErr() if (typeof obj.remote !== "string") exitTypeErr() const syncMode: string = typeof obj.syncMode === "string" ? obj.syncMode : "twoWay"