File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env php
2
2
<?php
3
-
3
+ $ dir = getcwd ();
4
4
if (is_file ($ autoload = __DIR__ . '/vendor/autoload.php ' )) {
5
- require $ autoload ;
5
+ require_once $ autoload ;
6
6
} elseif (is_file ($ autoload = __DIR__ . '/../../autoload.php ' )) {
7
- require $ autoload ;
7
+ require_once $ autoload ;
8
8
} else {
9
9
fwrite (STDERR ,
10
10
'You must set up the project dependencies, run the following commands: ' . PHP_EOL .
@@ -24,7 +24,7 @@ use Symfony\Component\Console\Application;
24
24
25
25
$ application = new Application ('Composer Git Hooks ' , 'v2.2.0 ' );
26
26
27
- $ hooks = Hook::getValidHooks ();
27
+ $ hooks = Hook::getValidHooks ($ dir );
28
28
$ application ->add (new AddCommand ($ hooks ));
29
29
$ application ->add (new UpdateCommand ($ hooks ));
30
30
$ application ->add (new RemoveCommand ($ hooks ));
Original file line number Diff line number Diff line change @@ -9,11 +9,13 @@ class Hook
9
9
/**
10
10
* Get scripts section of the composer config file.
11
11
*
12
+ * @param $dir string dir where to look for composer.json
13
+ *
12
14
* @return array
13
15
*/
14
- public static function getValidHooks ()
16
+ public static function getValidHooks ($ dir )
15
17
{
16
- $ contents = file_get_contents (' composer.json ' );
18
+ $ contents = file_get_contents ("{ $ dir } / composer.json" );
17
19
$ json = json_decode ($ contents , true );
18
20
$ hooks = array_merge (
19
21
isset ($ json ['scripts ' ]) ? $ json ['scripts ' ] : [],
You can’t perform that action at this time.
0 commit comments