From 68c1074de1afa4d7ac3978ddccd30d608236c9f4 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 29 May 2025 11:29:29 +0100 Subject: [PATCH] Updates --- dist/lib/watch/folders.js | 11 ++++++++--- dist/test/test-1/folder-1/test.js | 1 + dist/test/test-1/folder-2/test-file-2.js | 1 + dist/test/test-1/folder-2/test.js | 1 + dist/types/index.d.ts | 1 + lib/sync.ts | 4 +++- lib/watch/folders.ts | 9 ++++++++- package.json | 2 +- types/index.ts | 1 + 9 files changed, 25 insertions(+), 6 deletions(-) diff --git a/dist/lib/watch/folders.js b/dist/lib/watch/folders.js index 30019f6..6c11f08 100644 --- a/dist/lib/watch/folders.js +++ b/dist/lib/watch/folders.js @@ -98,7 +98,7 @@ function watchFolders(_a) { }); } function sync({ options, dirs, dirPath, init }) { - var _a; + var _a, _b; const dstDirs = dirs.filter((dr) => { if (typeof dr == "string") return dr !== dirPath; @@ -111,9 +111,14 @@ function sync({ options, dirs, dirPath, init }) { if (options === null || options === void 0 ? void 0 : options.delete) { cmdArray.push("--delete"); } - if ((_a = options === null || options === void 0 ? void 0 : options.exclude) === null || _a === void 0 ? void 0 : _a[0]) { + if ((_a = options === null || options === void 0 ? void 0 : options.include) === null || _a === void 0 ? void 0 : _a[0]) { + options.include.forEach((excl) => { + cmdArray.push(`--include='${excl}'`); + }); + } + if ((_b = options === null || options === void 0 ? void 0 : options.exclude) === null || _b === void 0 ? void 0 : _b[0]) { options.exclude.forEach((excl) => { - cmdArray.push(`--exclude '${excl}'`); + cmdArray.push(`--exclude='${excl}'`); }); } const dstDr = dstDirs[j]; diff --git a/dist/test/test-1/folder-1/test.js b/dist/test/test-1/folder-1/test.js index c8ad2e5..e2737d0 100644 --- a/dist/test/test-1/folder-1/test.js +++ b/dist/test/test-1/folder-1/test.js @@ -1,2 +1,3 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const testVar = 3; diff --git a/dist/test/test-1/folder-2/test-file-2.js b/dist/test/test-1/folder-2/test-file-2.js index c8ad2e5..22ef2f1 100644 --- a/dist/test/test-1/folder-2/test-file-2.js +++ b/dist/test/test-1/folder-2/test-file-2.js @@ -1,2 +1,3 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const testVar = 5; diff --git a/dist/test/test-1/folder-2/test.js b/dist/test/test-1/folder-2/test.js index c8ad2e5..e2737d0 100644 --- a/dist/test/test-1/folder-2/test.js +++ b/dist/test/test-1/folder-2/test.js @@ -1,2 +1,3 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const testVar = 3; diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts index 662277a..0db37f8 100644 --- a/dist/types/index.d.ts +++ b/dist/types/index.d.ts @@ -15,6 +15,7 @@ export interface TurboSyncFileObject { export interface TurboSyncOptions { delete?: boolean; exclude?: string[]; + include?: string[]; interval?: number; } export interface SyncFilesFnParams { diff --git a/lib/sync.ts b/lib/sync.ts index dc4ce92..d13e99a 100644 --- a/lib/sync.ts +++ b/lib/sync.ts @@ -1,13 +1,15 @@ import { spawn } from "child_process"; import watchFiles from "./watch/files"; import watchFolders from "./watch/folders"; +import { TurboSyncConfigObject } from "../types"; const confFileProvidedJSON = process.argv[process.argv.length - 1]; global.SYNCING = false; try { - const configFileObject = JSON.parse(confFileProvidedJSON); + const configFileObject: TurboSyncConfigObject = + JSON.parse(confFileProvidedJSON); console.log(`Running '${configFileObject.title}' ...`); diff --git a/lib/watch/folders.ts b/lib/watch/folders.ts index b14e765..f5146a1 100644 --- a/lib/watch/folders.ts +++ b/lib/watch/folders.ts @@ -116,9 +116,15 @@ function sync({ options, dirs, dirPath, init }: SyncFoldersSyncFnParams) { cmdArray.push("--delete"); } + if (options?.include?.[0]) { + options.include.forEach((excl) => { + cmdArray.push(`--include='${excl}'`); + }); + } + if (options?.exclude?.[0]) { options.exclude.forEach((excl) => { - cmdArray.push(`--exclude '${excl}'`); + cmdArray.push(`--exclude='${excl}'`); }); } @@ -138,6 +144,7 @@ function sync({ options, dirs, dirPath, init }: SyncFoldersSyncFnParams) { path.normalize(dstDr) + "/" ); const cmd = cmdArray.join(" "); + execSync(cmd, { stdio: "inherit", }); diff --git a/package.json b/package.json index 894cbde..3086d21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/turbosync", - "version": "1.0.5", + "version": "1.0.6", "module": "dist/index.js", "scripts": { "start": "node dist/index.js", diff --git a/types/index.ts b/types/index.ts index a757c59..f02c29e 100644 --- a/types/index.ts +++ b/types/index.ts @@ -18,6 +18,7 @@ export interface TurboSyncFileObject { export interface TurboSyncOptions { delete?: boolean; exclude?: string[]; + include?: string[]; interval?: number; }