From 44c5c19050b2b7d04a755c910550ca1616ca2c31 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Thu, 25 Dec 2025 06:04:03 +0100 Subject: [PATCH] Updates --- dist/utils/grab-dir-names.d.ts | 1 + dist/utils/grab-dir-names.js | 3 ++- dist/utils/sync.js | 6 ++++++ package.json | 2 +- utils/grab-dir-names.ts | 3 ++- utils/sync.ts | 9 +++++++++ 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dist/utils/grab-dir-names.d.ts b/dist/utils/grab-dir-names.d.ts index c0a605d..b263458 100644 --- a/dist/utils/grab-dir-names.d.ts +++ b/dist/utils/grab-dir-names.d.ts @@ -2,4 +2,5 @@ export default function grabDirNames(): { rootDir: string; syncConfigFileName: string; syncConfigFilePath: string; + ignoreFileName: string; }; diff --git a/dist/utils/grab-dir-names.js b/dist/utils/grab-dir-names.js index 726b50b..f9f69c6 100644 --- a/dist/utils/grab-dir-names.js +++ b/dist/utils/grab-dir-names.js @@ -9,5 +9,6 @@ function grabDirNames() { const rootDir = process.cwd(); const syncConfigFileName = "__trsyc.json"; const syncConfigFilePath = path_1.default.join(rootDir, syncConfigFileName); - return { rootDir, syncConfigFileName, syncConfigFilePath }; + const ignoreFileName = "turbosync.ignore"; + return { rootDir, syncConfigFileName, syncConfigFilePath, ignoreFileName }; } diff --git a/dist/utils/sync.js b/dist/utils/sync.js index 330c0e9..27fd38b 100644 --- a/dist/utils/sync.js +++ b/dist/utils/sync.js @@ -17,6 +17,7 @@ const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const util_1 = __importDefault(require("util")); const child_process_1 = require("child_process"); +const grab_dir_names_1 = __importDefault(require("./grab-dir-names")); const execPromise = util_1.default.promisify(child_process_1.exec); function sync(_a) { return __awaiter(this, arguments, void 0, function* ({ options, dirs, dirPath, isFiles, firstRun, }) { @@ -28,6 +29,8 @@ function sync(_a) { return dr.path !== dirPath; return false; }); + const { ignoreFileName } = (0, grab_dir_names_1.default)(); + const rsyncIgnoreFile = path_1.default.join(dirPath, ignoreFileName); const rsyncTrailingSlash = isFiles ? "" : "/"; const allCommandsArr = []; for (let j = 0; j < dstDirs.length; j++) { @@ -41,6 +44,9 @@ function sync(_a) { cmdArray.push(`--include='${incl}'`); }); } + if (fs_1.default.existsSync(rsyncIgnoreFile)) { + cmdArray.push(`--exclude-from=${rsyncIgnoreFile}`); + } if ((_c = options === null || options === void 0 ? void 0 : options.exclude) === null || _c === void 0 ? void 0 : _c[0]) { options.exclude.forEach((excl) => { cmdArray.push(`--exclude='${excl}'`); diff --git a/package.json b/package.json index faf630e..c5d750e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/turbosync", - "version": "1.2.4", + "version": "1.2.5", "module": "dist/index.js", "scripts": { "start": "node dist/index.js", diff --git a/utils/grab-dir-names.ts b/utils/grab-dir-names.ts index 90a0c92..d2bd6ae 100644 --- a/utils/grab-dir-names.ts +++ b/utils/grab-dir-names.ts @@ -4,6 +4,7 @@ export default function grabDirNames() { const rootDir = process.cwd(); const syncConfigFileName = "__trsyc.json"; const syncConfigFilePath = path.join(rootDir, syncConfigFileName); + const ignoreFileName = "turbosync.ignore"; - return { rootDir, syncConfigFileName, syncConfigFilePath }; + return { rootDir, syncConfigFileName, syncConfigFilePath, ignoreFileName }; } diff --git a/utils/sync.ts b/utils/sync.ts index fe08336..0207911 100644 --- a/utils/sync.ts +++ b/utils/sync.ts @@ -3,6 +3,7 @@ import path from "path"; import util from "util"; import { exec } from "child_process"; import { SyncFoldersSyncFnParams } from "../types"; +import grabDirNames from "./grab-dir-names"; const execPromise = util.promisify(exec); @@ -19,6 +20,10 @@ export default async function sync({ return false; }); + const { ignoreFileName } = grabDirNames(); + + const rsyncIgnoreFile = path.join(dirPath, ignoreFileName); + const rsyncTrailingSlash = isFiles ? "" : "/"; const allCommandsArr: string[][] = []; @@ -38,6 +43,10 @@ export default async function sync({ }); } + if (fs.existsSync(rsyncIgnoreFile)) { + cmdArray.push(`--exclude-from=${rsyncIgnoreFile}`); + } + if (options?.exclude?.[0]) { options.exclude.forEach((excl) => { cmdArray.push(`--exclude='${excl}'`);