1- const process = require ( 'node:process' )
21const satisfies = require ( 'semver/functions/satisfies' )
32const validRange = require ( 'semver/ranges/valid' )
3+ const currentEnv = require ( './current-env.js' )
44
55/*
66
@@ -48,14 +48,16 @@ function checkDev (wanted = {}, current = {}, opts = {}) {
4848 failures [ env ] = w
4949 break
5050 }
51- if ( validRange ( w . version ) ) {
52- if ( ! satisfies ( currentEnv . version , w . version , opts . semver ) ) {
51+ if ( w . version ) {
52+ if ( validRange ( w . version ) ) {
53+ if ( ! satisfies ( currentEnv . version , w . version , opts . semver ) ) {
54+ failures [ env ] = w
55+ break
56+ }
57+ } else if ( currentEnv . version !== w . version ) {
5358 failures [ env ] = w
5459 break
5560 }
56- } else if ( currentEnv . version !== w . version ) {
57- failures [ env ] = w
58- break
5961 }
6062 }
6163 }
@@ -86,19 +88,15 @@ function checkEngine (target, npmVer, nodeVer, force = false) {
8688 }
8789}
8890
89- function isMusl ( file ) {
90- return file . includes ( 'libc.musl-' ) || file . includes ( 'ld-musl-' )
91- }
92-
9391function checkPlatform ( target , force = false , environment = { } ) {
9492 if ( force ) {
9593 return
9694 }
9795
98- const platform = environment . os || process . platform
99- const arch = environment . cpu || process . arch
96+ const platform = environment . os || currentEnv . os ( )
97+ const cpu = environment . cpu || currentEnv . cpu ( )
10098 const osOk = target . os ? checkList ( platform , target . os ) : true
101- const cpuOk = target . cpu ? checkList ( arch , target . cpu ) : true
99+ const cpuOk = target . cpu ? checkList ( cpu , target . cpu ) : true
102100
103101 let libcOk = true
104102 let libcFamily = null
@@ -109,12 +107,7 @@ function checkPlatform (target, force = false, environment = {}) {
109107 } else if ( platform !== 'linux' ) {
110108 libcOk = false
111109 } else {
112- const report = process . report . getReport ( )
113- if ( report . header ?. glibcVersionRuntime ) {
114- libcFamily = 'glibc'
115- } else if ( Array . isArray ( report . sharedObjects ) && report . sharedObjects . some ( isMusl ) ) {
116- libcFamily = 'musl'
117- }
110+ libcFamily = currentEnv . libcFamily ( )
118111 libcOk = libcFamily ? checkList ( libcFamily , target . libc ) : false
119112 }
120113 }
@@ -124,7 +117,7 @@ function checkPlatform (target, force = false, environment = {}) {
124117 pkgid : target . _id ,
125118 current : {
126119 os : platform ,
127- cpu : arch ,
120+ cpu,
128121 libc : libcFamily ,
129122 } ,
130123 required : {
0 commit comments