mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +00:00
fix:获取npm和cnpm版本号的函数优化
This commit is contained in:
parent
1e1a18cb41
commit
57bcd6ed1f
@ -81,8 +81,14 @@ class Version
|
||||
public static function getNpmVersion()
|
||||
{
|
||||
$execOut = CommandExec::instance(false)->getOutputFromPopen('npm-v');
|
||||
if ($execOut && isset($execOut[0]) && self::checkDigitalVersion($execOut[0])) {
|
||||
return $execOut[0];
|
||||
if ($execOut) {
|
||||
if (isset($execOut[0]) && self::checkDigitalVersion($execOut[0])) {
|
||||
return $execOut[0];
|
||||
} else if (isset($execOut[1]) && self::checkDigitalVersion($execOut[1])) {
|
||||
return $execOut[1];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -91,9 +97,10 @@ class Version
|
||||
public static function getCnpmVersion()
|
||||
{
|
||||
$execOut = CommandExec::instance(false)->getOutputFromPopen('cnpm-v');
|
||||
if ($execOut && isset($execOut[0])) {
|
||||
$preg = '/cnpm@(.+?) \(/is';
|
||||
preg_match($preg, $execOut[0], $result);
|
||||
if ($execOut) {
|
||||
$execOut = implode('', $execOut);
|
||||
$preg = '/cnpm@(.+?) \(/is';
|
||||
preg_match($preg, $execOut, $result);
|
||||
return $result[1] ?? false;
|
||||
} else {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user