File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed
Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 254254 */
255255 'artisan_path ' => base_path ('artisan ' ),
256256
257+ /*
258+ |--------------------------------------------------------------------------
259+ | Laravel Sail
260+ |--------------------------------------------------------------------------
261+ |
262+ | If you are using Laravel Sail you may not have local PHP or Composer.
263+ |
264+ | This configuration option allows you to use local Git but still run Artisan commands with `sail` in front of them.
265+ |
266+ | The `artisan_path` configuration is ignored.
267+ |
268+ */
269+ 'use_sail ' => false ,
270+
257271 /*
258272 |--------------------------------------------------------------------------
259273 | Validate paths
Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then
44 exec < /dev/tty
55fi
66
7- php {artisanPath} {command} $@ >&2
7+ { php| sail} {artisanPath} {command} $@ >&2
Original file line number Diff line number Diff line change @@ -58,11 +58,25 @@ public function install(string $hookName): void
5858
5959 $ hookPath = $ this ->getGitHooksDir ().'/ ' .$ hookName ;
6060 $ hookScript = str_replace (
61- [ '{command} ' , ' {artisanPath} ' ] ,
62- [ $ command, config ( ' git-hooks.artisan_path ' )] ,
61+ '{command} ' ,
62+ $ command ,
6363 (string ) $ this ->getHookStub ()
6464 );
6565
66+ if (config ('git-hooks.use_sail ' )) {
67+ $ hookScript = str_replace (
68+ ['{php|sail} ' , '{artisanPath} ' ],
69+ ['vendor/bin/sail ' , 'artisan ' ],
70+ $ hookScript
71+ );
72+ } else {
73+ $ hookScript = str_replace (
74+ ['{php|sail} ' , '{artisanPath} ' ],
75+ ['php ' , config ('git-hooks.artisan_path ' )],
76+ $ hookScript
77+ );
78+ }
79+
6680 file_put_contents ($ hookPath , $ hookScript );
6781 chmod ($ hookPath , 0777 );
6882 }
You can’t perform that action at this time.
0 commit comments