Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions packages/build/src/plugins/compatibility.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _pEvery from 'p-every'
import pLocate from 'p-locate'
import { type PackageJson } from 'read-package-up'
import semver from 'semver'
Expand All @@ -9,9 +8,6 @@ import { SystemLogger } from '../plugins_core/types.js'
import { PluginVersion } from './list.js'
import { CONDITIONS } from './plugin_conditions.js'

// the types of that package seem to be not correct and demand a `pEvery.default()` usage which is wrong
const pEvery = _pEvery as unknown as typeof import('p-every').default

/**
* Retrieve the `expectedVersion` of a plugin:
* - This is the version which should be run
Expand Down Expand Up @@ -128,9 +124,13 @@ const getCompatibleEntry = async function ({
return false
}

return await pEvery(conditions, async ({ type, condition }) =>
CONDITIONS[type].test(condition as any, { nodeVersion, packageJson, packagePath, buildDir }),
)
return (
await Promise.all(
conditions.map(async ({ type, condition }) =>
CONDITIONS[type].test(condition as any, { nodeVersion, packageJson, packagePath, buildDir }),
),
)
).every(Boolean)
})

if (compatibleEntry) {
Expand Down Expand Up @@ -192,9 +192,13 @@ const getFirstCompatibleEntry = async function ({
return true
}

return await pEvery(conditions, async ({ type, condition }) =>
CONDITIONS[type].test(condition as any, { nodeVersion, packageJson, packagePath, buildDir }),
)
return (
await Promise.all(
conditions.map(async ({ type, condition }) =>
CONDITIONS[type].test(condition as any, { nodeVersion, packageJson, packagePath, buildDir }),
),
)
).every(Boolean)
})

if (compatibleEntry) {
Expand Down
14 changes: 7 additions & 7 deletions packages/build/src/plugins/plugin_conditions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { join } from 'path'

import _pEvery from 'p-every'
import { type PackageJson } from 'read-package-up'
import semver from 'semver'

Expand All @@ -9,9 +8,6 @@ import { resolvePath } from '../utils/resolve.js'

import { type PluginVersion } from './list.js'

// the types of that package seem to be not correct and demand a `pEvery.default()` usage which is wrong
const pEvery = _pEvery as unknown as typeof import('p-every').default

type ConditionContext = {
nodeVersion: string
packageJson: PackageJson
Expand Down Expand Up @@ -53,9 +49,13 @@ const siteDependenciesTest = async function (
}
}

return await pEvery(Object.entries(allowedSiteDependencies), ([dependencyName, allowedVersion]) =>
siteDependencyTest({ dependencyName, allowedVersion, siteDependencies, buildDir }),
)
return (
await Promise.all(
Object.entries(allowedSiteDependencies).map(async ([dependencyName, allowedVersion]) =>
siteDependencyTest({ dependencyName, allowedVersion, siteDependencies, buildDir }),
),
)
).every(Boolean)
}

const siteDependencyTest = async function ({
Expand Down
Loading