This commit is contained in:
Benjamin Toby 2025-05-29 11:29:29 +01:00
parent accf486151
commit 68c1074de1
9 changed files with 25 additions and 6 deletions

View File

@ -98,7 +98,7 @@ function watchFolders(_a) {
}); });
} }
function sync({ options, dirs, dirPath, init }) { function sync({ options, dirs, dirPath, init }) {
var _a; var _a, _b;
const dstDirs = dirs.filter((dr) => { const dstDirs = dirs.filter((dr) => {
if (typeof dr == "string") if (typeof dr == "string")
return dr !== dirPath; return dr !== dirPath;
@ -111,9 +111,14 @@ function sync({ options, dirs, dirPath, init }) {
if (options === null || options === void 0 ? void 0 : options.delete) { if (options === null || options === void 0 ? void 0 : options.delete) {
cmdArray.push("--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) => { options.exclude.forEach((excl) => {
cmdArray.push(`--exclude '${excl}'`); cmdArray.push(`--exclude='${excl}'`);
}); });
} }
const dstDr = dstDirs[j]; const dstDr = dstDirs[j];

View File

@ -1,2 +1,3 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const testVar = 3;

View File

@ -1,2 +1,3 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const testVar = 5;

View File

@ -1,2 +1,3 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const testVar = 3;

View File

@ -15,6 +15,7 @@ export interface TurboSyncFileObject {
export interface TurboSyncOptions { export interface TurboSyncOptions {
delete?: boolean; delete?: boolean;
exclude?: string[]; exclude?: string[];
include?: string[];
interval?: number; interval?: number;
} }
export interface SyncFilesFnParams { export interface SyncFilesFnParams {

View File

@ -1,13 +1,15 @@
import { spawn } from "child_process"; import { spawn } from "child_process";
import watchFiles from "./watch/files"; import watchFiles from "./watch/files";
import watchFolders from "./watch/folders"; import watchFolders from "./watch/folders";
import { TurboSyncConfigObject } from "../types";
const confFileProvidedJSON = process.argv[process.argv.length - 1]; const confFileProvidedJSON = process.argv[process.argv.length - 1];
global.SYNCING = false; global.SYNCING = false;
try { try {
const configFileObject = JSON.parse(confFileProvidedJSON); const configFileObject: TurboSyncConfigObject =
JSON.parse(confFileProvidedJSON);
console.log(`Running '${configFileObject.title}' ...`); console.log(`Running '${configFileObject.title}' ...`);

View File

@ -116,9 +116,15 @@ function sync({ options, dirs, dirPath, init }: SyncFoldersSyncFnParams) {
cmdArray.push("--delete"); cmdArray.push("--delete");
} }
if (options?.include?.[0]) {
options.include.forEach((excl) => {
cmdArray.push(`--include='${excl}'`);
});
}
if (options?.exclude?.[0]) { if (options?.exclude?.[0]) {
options.exclude.forEach((excl) => { 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) + "/" path.normalize(dstDr) + "/"
); );
const cmd = cmdArray.join(" "); const cmd = cmdArray.join(" ");
execSync(cmd, { execSync(cmd, {
stdio: "inherit", stdio: "inherit",
}); });

View File

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

View File

@ -18,6 +18,7 @@ export interface TurboSyncFileObject {
export interface TurboSyncOptions { export interface TurboSyncOptions {
delete?: boolean; delete?: boolean;
exclude?: string[]; exclude?: string[];
include?: string[];
interval?: number; interval?: number;
} }