PHPCSStandards / composer-installer

Composer installer for PHP_CodeSniffer coding standards
https://packagist.org/packages/dealerdirect/phpcodesniffer-composer-installer
MIT License
552 stars 36 forks source link

Bugfix: Composer scripts/commands broken in 0.6.0 update #105

Closed BrianHenryIE closed 4 years ago

BrianHenryIE commented 4 years ago

After the 0.6.0 update, Composer's scripts/post-install-cmd and scripts/post-update-cmd were no longer running.

This was due to PHP exiting outright rather than returning the $exitCode.

Potherca commented 4 years ago

Hi! Thank you for taking the time to report this issue and suggest a fix.

I will look into this today and (hopefully) merge and deploy a fix for this tomorrow.

For now, I'd like to make a reproduction scenario and an automated test to validate the correct behaviour.

Any updates will be posted here.

BrianHenryIE commented 4 years ago

Create a new directory with composer.json:

{
  "require-dev": {
    "dealerdirect/phpcodesniffer-composer-installer": "0.5"
  },
  "scripts": {
    "post-install-cmd": [
      "echo \"Success\""
    ],
    "post-update-cmd": [
      "echo \"Success\""
    ]
  }
}

Execute composer install and observe "Success".

Change the version number to 0.6. Run composer update twice. All subsequent invocations of composer install or composer update will fail to print "Success". Return to version 0.5. Run composer update twice. All subsequent invocations will succeed.

Potherca commented 4 years ago

Thank you for the detailed description! 👍 My test scenarios for this issue had a similar setup, but the details helped speed things up a bit.

The change fixes all the scenarios I created for this issue. Since they do not break any of the already existing test scenarios, I am merging this.

Thanks again for your help!

Potherca commented 4 years ago

The fix for this issue has been release as part of v0.6.2. Feel free to update your project(s) as needed.