This commit is contained in:
2025-11-20 08:02:54 +01:00
parent 822778d43b
commit fde40e8ece
8 changed files with 28 additions and 2 deletions
+12
View File
@@ -1,14 +1,17 @@
import fs from "fs";
import path from "path";
import { TurboSyncConfigObject } from "../types";
type Params = {
dirs?: string[];
files?: string[];
config: TurboSyncConfigObject;
};
export default function getLatestSource({
dirs,
files,
config,
}: Params): string | undefined {
let latestDir = undefined;
let latestMtime = 0;
@@ -35,6 +38,10 @@ export default function getLatestSource({
}
}
if (latestDir) {
if (isDirEmptySync(latestDir)) return undefined;
}
return latestDir;
}
@@ -65,3 +72,8 @@ function getLatestDirMtime(dir: string) {
return latestMtime;
}
function isDirEmptySync(path: string) {
const files = fs.readdirSync(path);
return files.length === 0;
}