@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
31 lines (29 loc) • 1.13 kB
JavaScript
import { getProjectRequire } from "@intlayer/config/utils";
//#region src/detectFormatCommand.ts
let cachedFormatCommand = null;
const detectFormatCommand = (configuration, projectRequireProp) => {
const { baseDir } = configuration.system;
const { formatCommand } = configuration.content;
const projectRequire = projectRequireProp ?? getProjectRequire(baseDir);
if (formatCommand) return formatCommand;
if (cachedFormatCommand !== null) return cachedFormatCommand;
try {
projectRequire.resolve("prettier");
cachedFormatCommand = "prettier --write \"{{file}}\" --log-level silent";
return cachedFormatCommand;
} catch (_error) {}
try {
projectRequire.resolve("biome");
cachedFormatCommand = "biome format \"{{file}}\" --write --log-level none";
return cachedFormatCommand;
} catch (_error) {}
try {
projectRequire.resolve("eslint");
cachedFormatCommand = "eslint --fix \"{{file}}\" --quiet || node -e \"process.exit(0)\"";
return cachedFormatCommand;
} catch (_error) {}
cachedFormatCommand = void 0;
};
//#endregion
export { detectFormatCommand };
//# sourceMappingURL=detectFormatCommand.mjs.map