mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-06 13:11:57 -05:00
fix(package‑is‑installable): use WantedEngine and WantedPlatform
PR #2099
This commit is contained in:
@@ -38,7 +38,4 @@ export type Engine = {
|
||||
pnpm: string,
|
||||
}
|
||||
|
||||
export type WantedEngine = {
|
||||
node?: string,
|
||||
pnpm?: string,
|
||||
}
|
||||
export type WantedEngine = Partial<Engine>
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import PnpmError from '@pnpm/error'
|
||||
|
||||
export class UnsupportedPlatformError extends PnpmError {
|
||||
public wanted: Platform
|
||||
public wanted: WantedPlatform
|
||||
public current: Platform
|
||||
|
||||
constructor (packageId: string, wanted: Platform, current: Platform) {
|
||||
constructor (packageId: string, wanted: WantedPlatform, current: Platform) {
|
||||
super('UNSUPPORTED_PLATFORM', `Unsupported platform for ${packageId}: wanted ${JSON.stringify(wanted)} (current: ${JSON.stringify(current)})`)
|
||||
this.wanted = wanted
|
||||
this.current = current
|
||||
}
|
||||
}
|
||||
|
||||
export default function checkPlatform (packageId: string, wantedPlatform: Platform) {
|
||||
export default function checkPlatform (
|
||||
packageId: string,
|
||||
wantedPlatform: WantedPlatform,
|
||||
) {
|
||||
const platform = process.platform
|
||||
const arch = process.arch
|
||||
let osOk = true
|
||||
@@ -34,6 +37,8 @@ export type Platform = {
|
||||
os: string | string[],
|
||||
}
|
||||
|
||||
export type WantedPlatform = Partial<Platform>
|
||||
|
||||
function checkList (value: string, list: string | string[]) {
|
||||
let tmp
|
||||
let match = false
|
||||
|
||||
@@ -2,12 +2,16 @@ import {
|
||||
installCheckLogger,
|
||||
skippedOptionalDependencyLogger,
|
||||
} from '@pnpm/core-loggers'
|
||||
import checkEngine, { UnsupportedEngineError } from './checkEngine'
|
||||
import checkEngine, { UnsupportedEngineError, WantedEngine } from './checkEngine'
|
||||
import checkPlatform, { UnsupportedPlatformError } from './checkPlatform'
|
||||
|
||||
export { Engine } from './checkEngine'
|
||||
export { Platform, WantedPlatform } from './checkPlatform'
|
||||
|
||||
export {
|
||||
UnsupportedEngineError,
|
||||
UnsupportedPlatformError,
|
||||
WantedEngine,
|
||||
}
|
||||
|
||||
export default function packageIsInstallable (
|
||||
@@ -15,10 +19,7 @@ export default function packageIsInstallable (
|
||||
pkg: {
|
||||
name: string,
|
||||
version: string,
|
||||
engines?: {
|
||||
node?: string,
|
||||
npm?: string,
|
||||
},
|
||||
engines?: WantedEngine,
|
||||
cpu?: string[],
|
||||
os?: string[],
|
||||
},
|
||||
@@ -62,10 +63,7 @@ export default function packageIsInstallable (
|
||||
export function checkPackage (
|
||||
pkgId: string,
|
||||
manifest: {
|
||||
engines?: {
|
||||
node?: string,
|
||||
npm?: string,
|
||||
},
|
||||
engines?: WantedEngine,
|
||||
cpu?: string[],
|
||||
os?: string[],
|
||||
},
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import logger from '@pnpm/logger'
|
||||
import { checkPackage, UnsupportedEngineError } from '@pnpm/package-is-installable'
|
||||
import { checkPackage, UnsupportedEngineError, WantedEngine } from '@pnpm/package-is-installable'
|
||||
import packageManager from './pnpmPkgJson'
|
||||
|
||||
export default function (
|
||||
export default function packageIsInstallable (
|
||||
pkgPath: string,
|
||||
pkg: {
|
||||
engines?: {
|
||||
node?: string,
|
||||
npm?: string,
|
||||
},
|
||||
engines?: WantedEngine,
|
||||
cpu?: string[],
|
||||
os?: string[],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user