mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
feat(find-workspace-packages): export findWorkspacePackagesNoCheck()
This commit is contained in:
5
.changeset/hot-melons-rule.md
Normal file
5
.changeset/hot-melons-rule.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/find-workspace-packages": minor
|
||||
---
|
||||
|
||||
Export findWorkspacePackagesNoCheck() for finding packages and skipping engine checks.
|
||||
@@ -14,6 +14,15 @@ export default async (
|
||||
patterns?: string[]
|
||||
}
|
||||
) => {
|
||||
const pkgs = await findWorkspacePackagesNoCheck(workspaceRoot, opts)
|
||||
for (const pkg of pkgs) {
|
||||
packageIsInstallable(pkg.dir, pkg.manifest, opts ?? {})
|
||||
}
|
||||
|
||||
return pkgs
|
||||
}
|
||||
|
||||
export async function findWorkspacePackagesNoCheck (workspaceRoot: string, opts?: { patterns?: string[] }): Promise<Project[]> {
|
||||
let patterns = opts?.patterns
|
||||
if (patterns == null) {
|
||||
const packagesManifest = await requirePackagesManifest(workspaceRoot)
|
||||
@@ -28,11 +37,7 @@ export default async (
|
||||
patterns,
|
||||
})
|
||||
pkgs.sort((pkg1: {dir: string}, pkg2: {dir: string}) => pkg1.dir.localeCompare(pkg2.dir))
|
||||
for (const pkg of pkgs) {
|
||||
packageIsInstallable(pkg.dir, pkg.manifest, opts ?? {})
|
||||
}
|
||||
|
||||
return pkgs as Project[]
|
||||
return pkgs
|
||||
}
|
||||
|
||||
async function requirePackagesManifest (dir: string): Promise<{packages?: string[]} | null> {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "pkg",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"pnpm": "10000.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
packages:
|
||||
- pkg
|
||||
@@ -1,4 +1,5 @@
|
||||
import { arrayOfWorkspacePackagesToMap } from '@pnpm/find-workspace-packages'
|
||||
import path from 'path'
|
||||
import { findWorkspacePackagesNoCheck, arrayOfWorkspacePackagesToMap } from '@pnpm/find-workspace-packages'
|
||||
|
||||
// This is supported for compatibility with Yarn's implementation
|
||||
// see https://github.com/pnpm/pnpm/issues/2648
|
||||
@@ -14,3 +15,9 @@ test('arrayOfWorkspacePackagesToMap() treats private packages with no version as
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('findWorkspacePackagesNoCheck() skips engine checks', async () => {
|
||||
const pkgs = await findWorkspacePackagesNoCheck(path.join(__dirname, '__fixtures__/bad-engine'))
|
||||
expect(pkgs.length).toBe(1)
|
||||
expect(pkgs[0].manifest.name).toBe('pkg')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user