@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
23 lines (21 loc) • 1.17 kB
JavaScript
import { cleanRemovedContentDeclaration } from "./cleanRemovedContentDeclaration.mjs";
import { formatPath } from "./utils/formatter.mjs";
import { loadLocalDictionaries } from "./loadDictionaries/loadLocalDictionaries.mjs";
import { handleContentDeclarationFileChange } from "./handleContentDeclarationFileChange.mjs";
import { getAppLogger } from "@intlayer/config/logger";
//#region src/handleContentDeclarationFileMoved.ts
const handleContentDeclarationFileMoved = async (oldFilePath, newFilePath, config) => {
const appLogger = getAppLogger(config);
appLogger(`File moved from ${formatPath(oldFilePath)} to ${formatPath(newFilePath)}`, { isVerbose: true });
let keysToKeep = [];
try {
keysToKeep = (await loadLocalDictionaries(newFilePath, config)).map((d) => d.key);
} catch {
appLogger(`Error parsing new file during move operation: ${formatPath(newFilePath)}`, { isVerbose: true });
}
await cleanRemovedContentDeclaration(oldFilePath, keysToKeep, config);
await handleContentDeclarationFileChange(newFilePath, config);
};
//#endregion
export { handleContentDeclarationFileMoved };
//# sourceMappingURL=handleContentDeclarationFileMoved.mjs.map