mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-19 03:39:21 +01:00
* cleanup scripts * Move helpers to package * Fixes scripts * Fix scripts * Formatting * Fix helpers import paths * Remove lucide-figma * Rename helpers package * Fix build * formatting * Adjust main build-icons file * Add export casing * Adds `exportModuleNameCasing` fro lab project * format files * Bump package version @lucide/build-icons * Revert changes in icons * Revert changes in PR yml * Fix lint issues * Fix site build * fix lint errors * Attempt fix linting * Fix lint errors
37 lines
1015 B
TypeScript
37 lines
1015 B
TypeScript
import { promises as fs, constants } from 'fs';
|
|
import path from 'path';
|
|
import { PackageItem } from '../theme/types';
|
|
|
|
const fileExist = (filePath) =>
|
|
fs
|
|
.access(filePath, constants.F_OK)
|
|
.then(() => true)
|
|
.catch(() => false);
|
|
|
|
const fetchPackages = async (): Promise<PackageItem[]> => {
|
|
const docsDir = path.resolve(process.cwd(), '../packages');
|
|
const fileNames = await (
|
|
await fs.readdir(docsDir)
|
|
).map((filename) => ({ filename, directory: docsDir }));
|
|
|
|
const packageJsons = await Promise.all(
|
|
fileNames.map(async ({ filename, directory }) => {
|
|
const filePath = path.resolve(directory, filename);
|
|
const fileStat = await fs.lstat(filePath);
|
|
|
|
if (!fileStat.isDirectory()) return null;
|
|
|
|
const jsonFilePath = path.resolve(filePath, 'package.json');
|
|
if (await fileExist(jsonFilePath)) {
|
|
return JSON.parse(await fs.readFile(jsonFilePath, 'utf-8'));
|
|
}
|
|
|
|
return null;
|
|
}),
|
|
);
|
|
|
|
return packageJsons;
|
|
};
|
|
|
|
export default fetchPackages;
|