This commit is contained in:
Benjamin Toby 2025-12-25 06:04:03 +01:00
parent a784e7f520
commit 44c5c19050
6 changed files with 21 additions and 3 deletions

View File

@ -2,4 +2,5 @@ export default function grabDirNames(): {
rootDir: string; rootDir: string;
syncConfigFileName: string; syncConfigFileName: string;
syncConfigFilePath: string; syncConfigFilePath: string;
ignoreFileName: string;
}; };

View File

@ -9,5 +9,6 @@ function grabDirNames() {
const rootDir = process.cwd(); const rootDir = process.cwd();
const syncConfigFileName = "__trsyc.json"; const syncConfigFileName = "__trsyc.json";
const syncConfigFilePath = path_1.default.join(rootDir, syncConfigFileName); const syncConfigFilePath = path_1.default.join(rootDir, syncConfigFileName);
return { rootDir, syncConfigFileName, syncConfigFilePath }; const ignoreFileName = "turbosync.ignore";
return { rootDir, syncConfigFileName, syncConfigFilePath, ignoreFileName };
} }

6
dist/utils/sync.js vendored
View File

@ -17,6 +17,7 @@ const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path")); const path_1 = __importDefault(require("path"));
const util_1 = __importDefault(require("util")); const util_1 = __importDefault(require("util"));
const child_process_1 = require("child_process"); 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); const execPromise = util_1.default.promisify(child_process_1.exec);
function sync(_a) { function sync(_a) {
return __awaiter(this, arguments, void 0, function* ({ options, dirs, dirPath, isFiles, firstRun, }) { return __awaiter(this, arguments, void 0, function* ({ options, dirs, dirPath, isFiles, firstRun, }) {
@ -28,6 +29,8 @@ function sync(_a) {
return dr.path !== dirPath; return dr.path !== dirPath;
return false; return false;
}); });
const { ignoreFileName } = (0, grab_dir_names_1.default)();
const rsyncIgnoreFile = path_1.default.join(dirPath, ignoreFileName);
const rsyncTrailingSlash = isFiles ? "" : "/"; const rsyncTrailingSlash = isFiles ? "" : "/";
const allCommandsArr = []; const allCommandsArr = [];
for (let j = 0; j < dstDirs.length; j++) { for (let j = 0; j < dstDirs.length; j++) {
@ -41,6 +44,9 @@ function sync(_a) {
cmdArray.push(`--include='${incl}'`); 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]) { if ((_c = options === null || options === void 0 ? void 0 : options.exclude) === null || _c === void 0 ? void 0 : _c[0]) {
options.exclude.forEach((excl) => { options.exclude.forEach((excl) => {
cmdArray.push(`--exclude='${excl}'`); cmdArray.push(`--exclude='${excl}'`);

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/turbosync", "name": "@moduletrace/turbosync",
"version": "1.2.4", "version": "1.2.5",
"module": "dist/index.js", "module": "dist/index.js",
"scripts": { "scripts": {
"start": "node dist/index.js", "start": "node dist/index.js",

View File

@ -4,6 +4,7 @@ export default function grabDirNames() {
const rootDir = process.cwd(); const rootDir = process.cwd();
const syncConfigFileName = "__trsyc.json"; const syncConfigFileName = "__trsyc.json";
const syncConfigFilePath = path.join(rootDir, syncConfigFileName); const syncConfigFilePath = path.join(rootDir, syncConfigFileName);
const ignoreFileName = "turbosync.ignore";
return { rootDir, syncConfigFileName, syncConfigFilePath }; return { rootDir, syncConfigFileName, syncConfigFilePath, ignoreFileName };
} }

View File

@ -3,6 +3,7 @@ import path from "path";
import util from "util"; import util from "util";
import { exec } from "child_process"; import { exec } from "child_process";
import { SyncFoldersSyncFnParams } from "../types"; import { SyncFoldersSyncFnParams } from "../types";
import grabDirNames from "./grab-dir-names";
const execPromise = util.promisify(exec); const execPromise = util.promisify(exec);
@ -19,6 +20,10 @@ export default async function sync({
return false; return false;
}); });
const { ignoreFileName } = grabDirNames();
const rsyncIgnoreFile = path.join(dirPath, ignoreFileName);
const rsyncTrailingSlash = isFiles ? "" : "/"; const rsyncTrailingSlash = isFiles ? "" : "/";
const allCommandsArr: string[][] = []; 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]) { if (options?.exclude?.[0]) {
options.exclude.forEach((excl) => { options.exclude.forEach((excl) => {
cmdArray.push(`--exclude='${excl}'`); cmdArray.push(`--exclude='${excl}'`);