Skip to content

Commit

Permalink
Improved composer plugin (#675)
Browse files Browse the repository at this point in the history
* Zero dependencies composer plugin

* Add debug info

* Fix configure task

* Debug

* Change flow

* Try other process implementation

* Fallback to old install / update logic - it was better

* Remove debugging and force ansii

* Add variable ansi support

* Try silent mode + cleanup tags

* Fix invalid args

* Additional props + debug

* Try stderr

* Improve code

* add docs

* Inspect update

* Improve uninstall logic

* Fix windows specific process error

* Fix some paths on windows
  • Loading branch information
veewee authored Nov 29, 2019
1 parent 75f9e2c commit 11e2593
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 109 deletions.
1 change: 1 addition & 0 deletions bump
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
11 changes: 10 additions & 1 deletion doc/installation/exotic.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ You can manipulate how GrumPHP works based on settings in your composer file:
"extra": {
"grumphp": {
"config-default-path": "path/to/grumphp.yml",
"project-path": "path/to/your/project/folder"
"project-path": "path/to/your/project/folder",
"disable-plugin": false
}
}
}
Expand Down Expand Up @@ -48,6 +49,14 @@ After changing a parameter, you might want to re-initialize your git hooks:
php ./vendor/bin/grumphp git:init
```

**disable-plugin**

*Default: false*

In some cases, you don't want composer to initialise GrumPHP automatically.
For example: on global installations activating the plugin is questionable.
Luckily you can opt-out on this behaviour.


## Changing paths by using environment variables

Expand Down
1 change: 1 addition & 0 deletions resources/config/console.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
arguments:
- '@config'
- '@grumphp.util.filesystem'
- '@GrumPHP\Util\Paths'
tags:
- { name: 'console.command' }
GrumPHP\Console\Command\RunCommand:
Expand Down
13 changes: 4 additions & 9 deletions src/Composer/DevelopmentIntegrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Composer\Script\Event;
use GrumPHP\Collection\ProcessArgumentsCollection;
use GrumPHP\Process\ProcessFactory;
use Symfony\Component\Filesystem\Filesystem;
use GrumPHP\Util\Filesystem;

class DevelopmentIntegrator
{
Expand All @@ -19,11 +19,11 @@ public static function integrate(Event $event): void
$filesystem = new Filesystem();

$composerBinDir = $event->getComposer()->getConfig()->get('bin-dir');
$executable = getcwd().'/bin/grumphp';
$executable = dirname(__DIR__, 2).$filesystem->ensureValidSlashes('/bin/grumphp');
$composerExecutable = $composerBinDir.'/grumphp';
$filesystem->copy(
self::noramlizePath($executable),
self::noramlizePath($composerExecutable)
$filesystem->ensureValidSlashes($executable),
$filesystem->ensureValidSlashes($composerExecutable)
);

$commandlineArgs = ProcessArgumentsCollection::forExecutable($composerExecutable);
Expand All @@ -42,9 +42,4 @@ public static function integrate(Event $event): void

$event->getIO()->write('<fg=yellow>'.$process->getOutput().'</fg=yellow>');
}

private static function noramlizePath(string $path): string
{
return str_replace('/', DIRECTORY_SEPARATOR, $path);
}
}
Loading

0 comments on commit 11e2593

Please sign in to comment.