diff --git a/src/File/Sudo.php b/src/File/Sudo.php index 56f61c24..92898132 100644 --- a/src/File/Sudo.php +++ b/src/File/Sudo.php @@ -4,6 +4,7 @@ namespace Php\Pie\File; +use Composer\Util\Platform as ComposerPlatform; use Php\Pie\Platform; use Php\Pie\Platform\TargetPlatform; use Symfony\Component\Process\ExecutableFinder; @@ -23,6 +24,10 @@ final class Sudo */ public static function find(): string { + if (ComposerPlatform::isWindows()) { + throw SudoNotFoundOnSystem::new(); + } + if (! is_string(self::$memoizedSudo)) { $sudo = (new ExecutableFinder())->find('sudo'); diff --git a/test/unit/File/SudoTest.php b/test/unit/File/SudoTest.php new file mode 100644 index 00000000..4c637c75 --- /dev/null +++ b/test/unit/File/SudoTest.php @@ -0,0 +1,27 @@ +expectException(SudoNotFoundOnSystem::class); + Sudo::find(); + } +}