mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-12 19:35:35 +08:00
* add initial windows runtime setup * add cool console output * doctor support windows base * add `add-path` and `remove-path` for bin/setup-runtime * fix composer.ps1 path * add windows system util * add windows cmd and doctor base check * add windows fallback for laravel/prompts * cd fix [skip ci] * dir separator and typo fix [skip ci]
27 lines
730 B
PHP
27 lines
730 B
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace SPC\builder\windows;
|
||
|
||
class SystemUtil
|
||
{
|
||
/**
|
||
* @param string $name 命令名称
|
||
* @param array $paths 寻找的目标路径(如果不传入,则使用环境变量 PATH)
|
||
* @return null|string 找到了返回命令路径,找不到返回 null
|
||
*/
|
||
public static function findCommand(string $name, array $paths = []): ?string
|
||
{
|
||
if (!$paths) {
|
||
$paths = explode(PATH_SEPARATOR, getenv('Path'));
|
||
}
|
||
foreach ($paths as $path) {
|
||
if (file_exists($path . DIRECTORY_SEPARATOR . $name)) {
|
||
return $path . DIRECTORY_SEPARATOR . $name;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
}
|