MCPcopy Index your code
hub / github.com/PatrickSys/codebase-context / isWorkspacePackageJson

Function isWorkspacePackageJson

src/utils/project-discovery.ts:66–86  ·  view source on GitHub ↗
(directoryPath: string)

Source from the content-addressed store, hash-verified

64}
65
66async function isWorkspacePackageJson(directoryPath: string): Promise<boolean> {
67 const packageJsonPath = path.join(directoryPath, 'package.json');
68 try {
69 const content = await fs.readFile(packageJsonPath, 'utf-8');
70 const parsed = JSON.parse(content) as { workspaces?: unknown };
71 if (Array.isArray(parsed.workspaces)) {
72 return parsed.workspaces.length > 0;
73 }
74 if (
75 parsed.workspaces &&
76 typeof parsed.workspaces === 'object' &&
77 !Array.isArray(parsed.workspaces) &&
78 'packages' in parsed.workspaces
79 ) {
80 return Array.isArray((parsed.workspaces as { packages?: unknown }).packages);
81 }
82 return false;
83 } catch {
84 return false;
85 }
86}
87
88async function classifyDirectory(
89 directoryPath: string,

Callers 1

classifyDirectoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected