Updates
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user