Skip to content

Commit

Permalink
[FrameworkBundle] make assets-install --relative equivalent to --syml…
Browse files Browse the repository at this point in the history
…ink --relative
  • Loading branch information
fabpot committed Oct 4, 2014
1 parent 181e460 commit 87d4039
Showing 1 changed file with 20 additions and 6 deletions.
Expand Up @@ -80,10 +80,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$bundlesDir = $targetArg.'/bundles/';
$filesystem->mkdir($bundlesDir, 0777);

if ($input->getOption('symlink')) {
$output->writeln('Trying to install assets as symbolic links.');
// relative implies symlink
$symlink = $input->getOption('symlink') || $input->getOption('relative');

if ($symlink) {
$output->writeln('Trying to install assets as <comment>symbolic links</comment>.');
} else {
$output->writeln('Installing assets as <comment>hard copies</comment>');
$output->writeln('Installing assets as <comment>hard copies</comment>.');
}

foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
Expand All @@ -94,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$filesystem->remove($targetDir);

if ($input->getOption('symlink')) {
if ($symlink) {
if ($input->getOption('relative')) {
$relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir));
} else {
Expand All @@ -105,8 +108,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
$filesystem->symlink($relativeOriginDir, $targetDir);
$output->writeln('The assets were installed using symbolic links.');
} catch (IOException $e) {
$this->hardCopy($originDir, $targetDir);
$output->writeln('It looks like your system doesn\'t support symbolic links, so the assets were installed by copying them.');
if (!$input->getOption('relative')) {
$this->hardCopy($originDir, $targetDir);
$output->writeln('It looks like your system doesn\'t support symbolic links, so the assets were installed by copying them.');
}

// try again without the relative option
try {
$filesystem->symlink($originDir, $targetDir);
$output->writeln('It looks like your system doesn\'t support relative symbolic links, so the assets were installed by using absolute symbolic links.');
} catch (IOException $e) {
$this->hardCopy($originDir, $targetDir);
$output->writeln('It looks like your system doesn\'t support symbolic links, so the assets were installed by copying them.');
}
}
} else {
$this->hardCopy($originDir, $targetDir);
Expand Down

0 comments on commit 87d4039

Please sign in to comment.