protected function doTarAdd($options, ResourceInterface $resource, $files, $recursive = true) { $files = (array) $files; $builder = $this->inflator->create(); if (!$recursive) { $builder->add('--no-recursion'); } $builder->add('--append')->add(sprintf('--file=%s', $resource->getResource())); foreach ((array) $options as $option) { $builder->add((string) $option); } // there will be an issue if the file starts with a dash // see --add-file=FILE $collection = $this->manager->handle(getcwd(), $files); $builder->setWorkingDirectory($collection->getContext()); $collection->forAll(function ($i, Resource $resource) use($builder) { return $builder->add($resource->getTarget()); }); $process = $builder->getProcess(); try { $process->run(); } catch (ProcessException $e) { $this->manager->cleanup($collection); throw $e; } $this->manager->cleanup($collection); if (!$process->isSuccessful()) { throw new RuntimeException(sprintf('Unable to execute the following command %s {output: %s}', $process->getCommandLine(), $process->getErrorOutput())); } return $files; }
/** * @inheritdoc */ protected function doAdd(ResourceInterface $resource, $files, $recursive) { $files = (array) $files; $builder = $this->inflator->create(); if ($recursive) { $builder->add('-r'); } $builder->add('-u')->add($resource->getResource()); $collection = $this->manager->handle(getcwd(), $files); $builder->setWorkingDirectory($collection->getContext()); $collection->forAll(function ($i, Resource $resource) use($builder) { return $builder->add($resource->getTarget()); }); $process = $builder->getProcess(); try { $process->run(); } catch (ProcessException $e) { $this->manager->cleanup($collection); throw $e; } $this->manager->cleanup($collection); if (!$process->isSuccessful()) { throw new RuntimeException(sprintf('Unable to execute the following command %s {output: %s}', $process->getCommandLine(), $process->getErrorOutput())); } }