Updates
This commit is contained in:
parent
822778d43b
commit
fde40e8ece
1
dist/lib/sync.js
vendored
1
dist/lib/sync.js
vendored
@ -51,6 +51,7 @@ try {
|
||||
const lastUpdated = (0, get_last_edited_src_1.default)({
|
||||
dirs: (0, grab_folders_files_string_paths_1.default)(configFileObject.folders),
|
||||
files: (0, grab_folders_files_string_paths_1.default)(configFileObject.files),
|
||||
config: configFileObject,
|
||||
});
|
||||
console.log(`Running '${configFileObject.title}' ...`);
|
||||
console.log(`Last Updated Path => '${lastUpdated || "N/A"}' ...`);
|
||||
|
||||
1
dist/types/index.d.ts
vendored
1
dist/types/index.d.ts
vendored
@ -17,6 +17,7 @@ export interface TurboSyncOptions {
|
||||
exclude?: string[];
|
||||
include?: string[];
|
||||
interval?: number;
|
||||
bootstrapLastEdited?: boolean;
|
||||
}
|
||||
export interface SyncFilesFnParams {
|
||||
files: (string | TurboSyncFileObject)[];
|
||||
|
||||
4
dist/utils/get-last-edited-src.d.ts
vendored
4
dist/utils/get-last-edited-src.d.ts
vendored
@ -1,6 +1,8 @@
|
||||
import { TurboSyncConfigObject } from "../types";
|
||||
type Params = {
|
||||
dirs?: string[];
|
||||
files?: string[];
|
||||
config: TurboSyncConfigObject;
|
||||
};
|
||||
export default function getLatestSource({ dirs, files, }: Params): string | undefined;
|
||||
export default function getLatestSource({ dirs, files, config, }: Params): string | undefined;
|
||||
export {};
|
||||
|
||||
10
dist/utils/get-last-edited-src.js
vendored
10
dist/utils/get-last-edited-src.js
vendored
@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = getLatestSource;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
function getLatestSource({ dirs, files, }) {
|
||||
function getLatestSource({ dirs, files, config, }) {
|
||||
let latestDir = undefined;
|
||||
let latestMtime = 0;
|
||||
const isFiles = files === null || files === void 0 ? void 0 : files[0];
|
||||
@ -28,6 +28,10 @@ function getLatestSource({ dirs, files, }) {
|
||||
console.error(`Error accessing ${pth}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
if (latestDir) {
|
||||
if (isDirEmptySync(latestDir))
|
||||
return undefined;
|
||||
}
|
||||
return latestDir;
|
||||
}
|
||||
function getLatestDirMtime(dir) {
|
||||
@ -55,3 +59,7 @@ function getLatestDirMtime(dir) {
|
||||
}
|
||||
return latestMtime;
|
||||
}
|
||||
function isDirEmptySync(path) {
|
||||
const files = fs_1.default.readdirSync(path);
|
||||
return files.length === 0;
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ try {
|
||||
const lastUpdated = getLatestSource({
|
||||
dirs: fldFileToStrArr(configFileObject.folders),
|
||||
files: fldFileToStrArr(configFileObject.files),
|
||||
config: configFileObject,
|
||||
});
|
||||
|
||||
console.log(`Running '${configFileObject.title}' ...`);
|
||||
|
||||
@ -20,6 +20,7 @@ export interface TurboSyncOptions {
|
||||
exclude?: string[];
|
||||
include?: string[];
|
||||
interval?: number;
|
||||
bootstrapLastEdited?: boolean;
|
||||
}
|
||||
|
||||
export interface SyncFilesFnParams {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user