Skip to content

Commit

Permalink
feat(findWorkspaceDir): detect workspace files (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Mar 3, 2025
1 parent 07b09ee commit bda0f16
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/packagejson/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ const lockFiles = [
"bun.lock",
];

const workspaceFiles = [
"pnpm-workspace.yaml",
"lerna.json",
"turbo.json",
"rush.json",
];

const FileCache = /* #__PURE__ */ new Map<string, Record<string, any>>();

/**
Expand Down Expand Up @@ -115,6 +122,14 @@ export async function findWorkspaceDir(
const startingFrom = _resolvePath(id, options);
options = { startingFrom, ...options } as ResolveOptions;

// Lookdown for known workspace files
try {
const r = await findFarthestFile(workspaceFiles, options);
return dirname(r);
} catch {
// Ignore
}

// Lookdown for .git/config
try {
const r = await findFarthestFile(".git/config", options);
Expand Down

0 comments on commit bda0f16

Please sign in to comment.