MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / loadFeatureSourceSync

Function loadFeatureSourceSync

apps/public/src/lib/features.ts:145–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143
144/** Sync loader for use in source.ts (same pattern as compareSource). */
145export function loadFeatureSourceSync(): FeatureData[] {
146 try {
147 const files = readdirSync(contentDir);
148 return files
149 .filter((file) => file.endsWith('.json'))
150 .map((file) => {
151 const slug = file.replace('.json', '');
152 const filePath = join(contentDir, file);
153 const fileContents = readFileSync(filePath, 'utf8');
154 const data = JSON.parse(fileContents) as Omit<FeatureData, 'url'>;
155 return { ...data, url: `/features/${slug}` };
156 });
157 } catch (error) {
158 if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];
159 console.error('Error loading feature source:', error);
160 return [];
161 }
162}

Callers 1

source.tsFile · 0.90

Calls 5

joinFunction · 0.85
replaceMethod · 0.80
parseMethod · 0.80
mapMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected