Skip to content

Commit

Permalink
Merge pull request #105 from JohnSunHope/node-kits/be-compatible-for-…
Browse files Browse the repository at this point in the history
…yarn-nohoist
  • Loading branch information
saqqdy authored Nov 21, 2024
2 parents 89df46f + dedd3d7 commit 826a5d9
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions packages/yarn-workspace-info/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { dirname } from '@node-kit/extra.path'
import { yarnWorkspaceRoot, yarnWorkspaceRootSync } from '@node-kit/yarn-workspace-root'

export type ManifestInfo = Record<string, unknown> & {
workspaces: string | string[]
workspaces: string | string[] | (Record<string, unknown> & { packages: [] })
}

export type WorkspaceInfo = Record<
Expand Down Expand Up @@ -41,12 +41,20 @@ export async function yarnWorkspaceInfo(
return null
}

console.info('root: ', root)
const manifest = (await readJSON(join(root, WORKSPACE_MANIFEST_FILENAME))) as ManifestInfo
const projects = await fg(([] as string[]).concat(manifest.workspaces), {
cwd: root,
ignore: DEFAULT_IGNORE_PATHS,
onlyDirectories: true
})
const projects = await fg(
([] as string[]).concat(
Array.isArray(manifest.workspaces) || typeof manifest.workspaces === 'string'
? manifest.workspaces
: manifest.workspaces.packages
),
{
cwd: root,
ignore: DEFAULT_IGNORE_PATHS,
onlyDirectories: true
}
)
const workspaceInfo: WorkspaceInfo = {}
for (const projectPath of projects) {
workspaceInfo[dirname(projectPath)] = {
Expand All @@ -70,11 +78,18 @@ export function yarnWorkspaceInfoSync(cwd: string = process.cwd()): WorkspaceInf
}

const manifest = readJSONSync(join(root, WORKSPACE_MANIFEST_FILENAME)) as ManifestInfo
const projects = fg.sync(([] as string[]).concat(manifest.workspaces), {
cwd: root,
ignore: DEFAULT_IGNORE_PATHS,
onlyDirectories: true
})
const projects = fg.sync(
([] as string[]).concat(
Array.isArray(manifest.workspaces) || typeof manifest.workspaces === 'string'
? manifest.workspaces
: manifest.workspaces.packages
),
{
cwd: root,
ignore: DEFAULT_IGNORE_PATHS,
onlyDirectories: true
}
)
const workspaceInfo: WorkspaceInfo = {}
for (const projectPath of projects) {
workspaceInfo[dirname(projectPath)] = {
Expand Down

0 comments on commit 826a5d9

Please sign in to comment.