public function onBeforeAutoloadDump() {

    // FIXME Composer call this AFTER the plugin remove, so we need this check to prevent a fatal error
    clearstatcache();
    if( file_exists( __DIR__ . '/Plugin.php' ) ) {

      //
      $filesystem = new Filesystem();
      $tmp        = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
      array_unshift( $tmp, $this->composer->getPackage() );

      $list = [];
      foreach( $tmp as $package ) {
        if( $package->getType() == static::PACKAGE_TYPE ) {

          // choose root directory based on the path (absolute path has no root) or package (main or vendor)
          if( $package === $this->composer->getPackage() ) $directory = $this->root;
          else $directory = $this->getDirectory( $package );

          // process autoloader
          $autoload = $package->getAutoload();
          if( isset( $autoload[ 'psr-4' ] ) ) {
            foreach( $autoload[ 'psr-4' ] as $namespace => $path ) {

              // don't handle multi directory namespace
              if( is_array( $path ) ) $this->io->writeError( 'Spoom\Composer: Ignoring multiple psr-4 namespaces of ' . $package->getPrettyName() );
              else {

                // normalize and ensure the trailing slash in the path
                $list[ $namespace ] = $filesystem->normalizePath( ( $filesystem->isAbsolutePath( $path ) ? '' : $directory ) . $path ) . '/';
              }
            }
          }
        }
      }

      $this->io->write( 'Spoom\Composer: Generating autoload file for ' . count( $list ) . ' extension(s)' );

      // create autoload file from the package list
      $this->writeAutoload( $list );
    }
  }