Skip to content

Commit

Permalink
Merge pull request #129 from lishaduck/fix-manifests
Browse files Browse the repository at this point in the history
Fix monorepo manifest reads
  • Loading branch information
jeffijoe authored Oct 25, 2024
2 parents 4435e49 + 06bb850 commit 6b9803f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/globber.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { join } from 'node:path'
import * as path from 'node:path'
import { createGlobber } from '../globber'

test('returns the current directory as a match', async () => {
const result = await createGlobber().glob(process.cwd(), 'package.json')
expect(result).toHaveLength(1)
expect(result[0]).toBe(join(process.cwd(), 'package.json'))
expect(result[0]).toBe(path.join(process.cwd(), 'package.json'))
})
5 changes: 1 addition & 4 deletions src/__tests__/type-syncer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ function buildSyncer() {
glob: jest.fn(async (pattern, _filename) => {
switch (pattern) {
case 'packages/*':
return [
'packages/package-1/package.json',
'packages/package-2/package.json',
]
return ['packages/package-1/', 'packages/package-2/']
default:
return []
}
Expand Down
7 changes: 4 additions & 3 deletions src/type-syncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ export function createTypeSyncer(
): Promise<ISyncResult> {
const dryRun = !!flags.dry
const syncOpts = await configService.readConfig(filePath, flags)
const { file, subPackages } = await getManifests(
const { file, subManifests } = await getManifests(
filePath,
globber,
syncOpts.ignoreProjects ?? [],
)

const syncedFiles: Array<ISyncedFile> = await Promise.all([
syncFile(filePath, file, syncOpts, dryRun),
...subPackages.map((p) => syncFile(p, null, syncOpts, dryRun)),
...subManifests.map((p) => syncFile(p, null, syncOpts, dryRun)),
])

return {
Expand All @@ -91,10 +91,11 @@ export function createTypeSyncer(
globber,
ignoredWorkspaces,
)
const subManifests = subPackages.map((p) => path.join(p, 'package.json'))

return {
file,
subPackages,
subManifests,
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/workspace-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'node:path'
import * as path from 'node:path'
import yaml from 'js-yaml'
import type * as fsUtils from './fs-utils'
import { IGlobber } from './globber'
Expand All @@ -17,6 +17,7 @@ export interface IWorkspaceResolverService {
* - `pnpm-workspace.yaml` `packages` field, as an array of globs.
*
* Path is relative to the current working directory.
* Note that this returns a list of directories, not paths to the manifests themselves.
*/
getWorkspaces(
packageJson: IPackageFile,
Expand Down

0 comments on commit 6b9803f

Please sign in to comment.