@ts-intl/dependency
Version:
I18n keys dependency analysis
30 lines (29 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDependenciesFs = void 0;
const fs_1 = require("fs");
const path_1 = require("path");
const getDependenciesByEntries_1 = require("./getDependenciesByEntries");
const getEntriesSync = (dirPath, rule = /\.tsx?$/) => {
if (!(0, fs_1.lstatSync)(dirPath).isDirectory())
return rule.test(dirPath) ? [dirPath] : [];
const res = [];
(0, fs_1.readdirSync)(dirPath).forEach((file) => {
res.push(...getEntriesSync((0, path_1.resolve)(dirPath, file)));
});
return res;
};
// const getEntries = async (dirPath: string, rule = /\.tsx?$/) => {
// const isDir = (await stat(dirPath)).isDirectory();
// if (!isDir) return rule.test(dirPath) ? [dirPath] : [];
// const res: string[] = [];
// (await readdir(dirPath)).forEach(async (file) => {
// const child = await getEntries(resolve(dirPath, file), rule);
// child.forEach((v) => res.push(v));
// });
// return res;
// };
const getDependenciesFs = (entry, opts, extractIntlKeysOpts) => {
return (0, getDependenciesByEntries_1.getDependenciesByEntries)(getEntriesSync(entry), opts, extractIntlKeysOpts);
};
exports.getDependenciesFs = getDependenciesFs;