diff --git a/src/Composer/Command/ArchiveCommand.php b/src/Composer/Command/ArchiveCommand.php index b70f06c27..6a4914a7e 100644 --- a/src/Composer/Command/ArchiveCommand.php +++ b/src/Composer/Command/ArchiveCommand.php @@ -42,7 +42,8 @@ class ArchiveCommand extends Command new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'), new InputOption('format', 'f', InputOption::VALUE_OPTIONAL, 'Format of the resulting archive: tar or zip'), new InputOption('dir', false, InputOption::VALUE_OPTIONAL, 'Write the archive to this directory'), - new InputOption('file', false, InputOption::VALUE_OPTIONAL, 'Write the archive with the given file name.'), + new InputOption('file', false, InputOption::VALUE_OPTIONAL, 'Write the archive with the given file name.' + .' Note that the format will be appended.'), )) ->setHelp(<<archive command creates an archive of the specified format diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index 656d2f7a2..4a9ce4a94 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -97,8 +97,8 @@ class ArchiveManager * @param PackageInterface $package The package to archive * @param string $format The format of the archive (zip, tar, ...) * @param string $targetDir The directory where to build the archive - * @param string|null $fileName The file name to use for the archive, or null to use the generated - * package name + * @param string|null $fileName The relative file name to use for the archive, or null to generate + * the package name. Note that the format will be appended to this name * @throws \InvalidArgumentException * @throws \RuntimeException * @return string The path of the created archive @@ -128,9 +128,9 @@ class ArchiveManager $filesystem = new Filesystem(); if(null === $fileName) { - $packageName = $fileName; - } else { $packageName = $this->getPackageFilename($package); + } else { + $packageName = $fileName; } // Archive filename diff --git a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php index d5f7300a9..082d6e0ca 100644 --- a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php @@ -70,7 +70,7 @@ class ArchiveManagerTest extends ArchiverTest $this->manager->archive($package, 'tar', $this->targetDir, $fileName); - $target = $this->getTargetName($package, 'tar', $fileName); + $target = $this->targetDir . "/" . $fileName . ".tar"; $this->assertFileExists($target); @@ -90,11 +90,12 @@ class ArchiveManagerTest extends ArchiverTest protected function getTargetName(PackageInterface $package, $format, $fileName = null) { - if(!is_null($fileName)) { - $packageName = $fileName; - } else { + if(null === $fileName) { $packageName = $this->manager->getPackageFilename($package); + } else { + $packageName = $fileName; } + $target = $this->targetDir.'/'.$packageName.'.'.$format; return $target;