octolab / cleaner

🛁 The Composer plugin to remove development files.
MIT License
15 stars 3 forks source link

Remove references to deleted directories/files from composer autoload files #6

Closed mlocati closed 8 years ago

mlocati commented 8 years ago

This is not mandatory, but it would be nice if this tool could remove references to the deleted files/directories from the composer autoload files:

For instance, if we delete the tests directory from package vendor1/package1, we should strip out the following line from vendor/composer/autoload_classmap.php:

  'VendorNamespace1\\Tests\\TestClass' => $vendorDir . '/vendor1/package1/tests/TestClass.php',
mlocati commented 8 years ago

I did the following test with the current plugin version:

Create this composer.json file:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/mlocati/class-loader"
    },
    {
      "type": "vcs",
      "url": "https://github.com/mlocati/log"
    }
  ],
  "require": {
    "symfony/class-loader": "99.*",
    "psr/log": "1.*"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": {
      "*": "dist"
    },
    "octolab/cleaner": {
      "clear": {
        "*": "*"
      }
    }
  }
}

Running composer install, vendor/composer/autoload_classmap.php contains references to the test classes of psr/log (as expected, since we're installing the official psr/log package).

Running composer require psr/log:99.* uses my forked version of psr/log (that specifies the files to be removed), and the references to the test classes are removed from composer autoload files... Great!

:+1: