Commit 4cacc76 1 parent c1964bd commit 4cacc76 Copy full SHA for 4cacc76
File tree 2 files changed +30
-4
lines changed
2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public function __construct()
15
15
public static function cwd (string $ path = '' ): string
16
16
{
17
17
if ($ path ) {
18
+ $ path = str_replace ('/ ' , DIRECTORY_SEPARATOR , $ path );
18
19
return getcwd () . DIRECTORY_SEPARATOR . $ path ;
19
20
}
20
21
@@ -23,9 +24,15 @@ public static function cwd(string $path = ''): string
23
24
24
25
public static function base_path (string $ path = '' ): string
25
26
{
26
- return Phar::running ()
27
+ if (! Phar::running ()) {
28
+ return base_path ($ path );
29
+ }
30
+
31
+ $ path = File::exists (Whisky::cwd ("vendor/bin/whisky " ))
27
32
? Whisky::cwd ("vendor/projektgopher/whisky/ {$ path }" )
28
- : base_path ($ path );
33
+ : self ::getGlobalComposerHome ().'/vendor/projektgopher/whisky/ ' .$ path ;
34
+
35
+ return str_replace ('/ ' , DIRECTORY_SEPARATOR , $ path );
29
36
}
30
37
31
38
public static function readConfig (string $ key ): string |array
@@ -36,4 +43,9 @@ public static function readConfig(string $key): string|array
36
43
37
44
return data_get ($ cfg , $ key );
38
45
}
46
+
47
+ public static function getGlobalComposerHome (): string
48
+ {
49
+ return rtrim (shell_exec ('composer -n config --global home ' ), "\n" );
50
+ }
39
51
}
Original file line number Diff line number Diff line change 4
4
# ########################
5
5
6
6
# Get the hook name from the first and only argument
7
- hook=$1
7
+ HOOK=$1
8
+
9
+ # Get the path to the whisky binary:
10
+ # First, check if it's in the vendor folder.
11
+ # If not, check the global composer folder.
12
+ # If not, print an error message and exit.
13
+ # This currently only supports windows when using git bash or WSL.
14
+ if [ -f " ./vendor/bin/whisky" ]; then
15
+ WHISKY=" ./vendor/bin/whisky"
16
+ elif [ -f " $( composer -n config --global home) /vendor/bin/whisky" ]; then
17
+ WHISKY=$( composer -n config --global home) /vendor/bin/whisky
18
+ else
19
+ printf " Whisky not found. Please run 'composer install' to install it.\n"
20
+ exit 1
21
+ fi
8
22
9
23
# Get a list of scripts to run sequencially for this hook
10
- SCRIPTS=$( ./vendor/bin/whisky scripts " $hook " )
24
+ SCRIPTS=$( $WHISKY scripts " $HOOK " )
11
25
12
26
# Make newlines the only separator
13
27
IFS=$' \n '
You can’t perform that action at this time.
0 commit comments