@@ -15,19 +15,19 @@ public function __construct()
15
15
public static function cwd (string $ path = '' ): string
16
16
{
17
17
if ($ path ) {
18
- return getcwd ().DIRECTORY_SEPARATOR .$ path ;
18
+ return Whisky:: normalizePath ( getcwd ().' / ' .$ path) ;
19
19
}
20
20
21
- return getcwd ();
21
+ return Whisky:: normalizePath ( getcwd () );
22
22
}
23
23
24
24
public static function bin (): string
25
25
{
26
- return match (true ) {
26
+ return Whisky:: normalizePath ( match (true ) {
27
27
self ::dogfooding () => self ::cwd ('whisky ' ),
28
28
self ::isRunningGlobally () => '/usr/local/bin/whisky ' , // TODO
29
29
default => self ::cwd ('vendor/bin/whisky ' ),
30
- };
30
+ }) ;
31
31
}
32
32
33
33
public static function dogfooding (): bool
@@ -43,9 +43,9 @@ public static function isRunningGlobally(): bool
43
43
44
44
public static function base_path (string $ path = '' ): string
45
45
{
46
- return Phar::running ()
46
+ return Whisky:: normalizePath ( Phar::running ()
47
47
? Whisky::cwd ("vendor/projektgopher/whisky/ {$ path }" )
48
- : base_path ($ path );
48
+ : base_path ($ path )) ;
49
49
}
50
50
51
51
public static function readConfig (string $ key ): string |array |null
@@ -56,4 +56,18 @@ public static function readConfig(string $key): string|array|null
56
56
57
57
return data_get ($ cfg , $ key );
58
58
}
59
+
60
+ public static function normalizePath ($ path ): string
61
+ {
62
+ if (Whisky::isWindows ()) {
63
+ return str_replace ('\\' , '/ ' , $ path );
64
+ }
65
+
66
+ return $ path ;
67
+ }
68
+
69
+ public static function isWindows (): bool
70
+ {
71
+ return str_starts_with (strtoupper (PHP_OS ), 'WIN ' );
72
+ }
59
73
}
0 commit comments