diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..d071feff1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +custom: https://packagist.com diff --git a/doc/01-basic-usage.md b/doc/01-basic-usage.md index 4981542e8..cc5ac5459 100644 --- a/doc/01-basic-usage.md +++ b/doc/01-basic-usage.md @@ -241,8 +241,14 @@ be in your project root, on the same level as `vendor` directory is. An example filename would be `src/Foo.php` containing an `Acme\Foo` class. After adding the [`autoload`](04-schema.md#autoload) field, you have to re-run -[`dump-autoload`](03-cli.md#dump-autoload) to re-generate the -`vendor/autoload.php` file. +this command : + +```sh +php composer.phar dump-autoload +``` + +This command will re-generate the `vendor/autoload.php` file. +See the [`dump-autoload`](03-cli.md#dump-autoload) section for more informations. Including that file will also return the autoloader instance, so you can store the return value of the include call in a variable and add more namespaces. diff --git a/doc/03-cli.md b/doc/03-cli.md index b2c4bc7b5..5c4638b7c 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -706,7 +706,7 @@ performance. * **--apcu:** Use APCu to cache found/not-found classes. * **--no-dev:** Disables autoload-dev rules. -## clear-cache (clearcache) +## clear-cache / clearcache / cc Deletes all content from Composer's cache directories. diff --git a/src/Composer/Command/ClearCacheCommand.php b/src/Composer/Command/ClearCacheCommand.php index 08ec04701..80e63d8ec 100644 --- a/src/Composer/Command/ClearCacheCommand.php +++ b/src/Composer/Command/ClearCacheCommand.php @@ -26,7 +26,7 @@ class ClearCacheCommand extends BaseCommand { $this ->setName('clear-cache') - ->setAliases(array('clearcache')) + ->setAliases(array('clearcache', 'cc')) ->setDescription('Clears composer\'s internal package cache.') ->setHelp( <<writeError('Creating a "' . $packageName . '" project at "' . $directory . '"'); + + $fs = new Filesystem(); + if (file_exists($directory)) { + if (!is_dir($directory)) { + throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.'); + } elseif (!$fs->isDirEmpty($directory)) { + throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.'); + } + } + if (null === $stability) { if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) { $stability = $match[1]; @@ -320,11 +338,6 @@ EOT throw new \InvalidArgumentException($errorMessage .'.'); } - if (null === $directory) { - $parts = explode("/", $name, 2); - $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts); - } - // handler Ctrl+C for unix-like systems if (function_exists('pcntl_async_signals')) { @mkdir($directory, 0777, true); diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index 160bae1d6..29c7fd82a 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -107,11 +107,11 @@ class ZipDownloader extends ArchiveDownloader $command = 'unzip -qq '.$overwrite.' '.ProcessExecutor::escape($file).' -d '.ProcessExecutor::escape($path); try { - if (0 === $this->process->execute($command, $ignoredOutput)) { + if (0 === $exitCode = $this->process->execute($command, $ignoredOutput)) { return true; } - $processError = new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); + $processError = new \RuntimeException('Failed to execute ('.$exitCode.') '.$command."\n\n".$this->process->getErrorOutput()); } catch (\Exception $e) { $processError = $e; } diff --git a/tests/Composer/Test/Downloader/ZipDownloaderTest.php b/tests/Composer/Test/Downloader/ZipDownloaderTest.php index 63c407218..eb57e67df 100644 --- a/tests/Composer/Test/Downloader/ZipDownloaderTest.php +++ b/tests/Composer/Test/Downloader/ZipDownloaderTest.php @@ -179,7 +179,7 @@ class ZipDownloaderTest extends TestCase /** * @expectedException \Exception - * @expectedExceptionMessage Failed to execute unzip + * @expectedExceptionMessage Failed to execute (1) unzip */ public function testSystemUnzipOnlyFailed() { @@ -305,7 +305,7 @@ class ZipDownloaderTest extends TestCase /** * @expectedException \Exception - * @expectedExceptionMessage Failed to execute unzip + * @expectedExceptionMessage Failed to execute (1) unzip */ public function testWindowsFallbackFailed() { diff --git a/tests/Composer/Test/Fixtures/functional/create-project-shows-full-hash-for-dev-packages.test b/tests/Composer/Test/Fixtures/functional/create-project-shows-full-hash-for-dev-packages.test index 2de92f067..357f51619 100644 --- a/tests/Composer/Test/Fixtures/functional/create-project-shows-full-hash-for-dev-packages.test +++ b/tests/Composer/Test/Fixtures/functional/create-project-shows-full-hash-for-dev-packages.test @@ -1,4 +1,4 @@ --RUN-- create-project --repository=packages.json -v seld/jsonlint %testDir% dev-master --EXPECT-ERROR-REGEX-- -{^Installing seld/jsonlint \(dev-master [a-f0-9]{40}\)} +{^Installing seld/jsonlint \(dev-master [a-f0-9]{40}\)}m