Skip to content

Commit 87d4039

Browse files
committed
[FrameworkBundle] make assets-install --relative equivalent to --symlink --relative
1 parent 181e460 commit 87d4039

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080
$bundlesDir = $targetArg.'/bundles/';
8181
$filesystem->mkdir($bundlesDir, 0777);
8282

83-
if ($input->getOption('symlink')) {
84-
$output->writeln('Trying to install assets as symbolic links.');
83+
// relative implies symlink
84+
$symlink = $input->getOption('symlink') || $input->getOption('relative');
85+
86+
if ($symlink) {
87+
$output->writeln('Trying to install assets as <comment>symbolic links</comment>.');
8588
} else {
86-
$output->writeln('Installing assets as <comment>hard copies</comment>');
89+
$output->writeln('Installing assets as <comment>hard copies</comment>.');
8790
}
8891

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

9598
$filesystem->remove($targetDir);
9699

97-
if ($input->getOption('symlink')) {
100+
if ($symlink) {
98101
if ($input->getOption('relative')) {
99102
$relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir));
100103
} else {
@@ -105,8 +108,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
105108
$filesystem->symlink($relativeOriginDir, $targetDir);
106109
$output->writeln('The assets were installed using symbolic links.');
107110
} catch (IOException $e) {
108-
$this->hardCopy($originDir, $targetDir);
109-
$output->writeln('It looks like your system doesn\'t support symbolic links, so the assets were installed by copying them.');
111+
if (!$input->getOption('relative')) {
112+
$this->hardCopy($originDir, $targetDir);
113+
$output->writeln('It looks like your system doesn\'t support symbolic links, so the assets were installed by copying them.');
114+
}
115+
116+
// try again without the relative option
117+
try {
118+
$filesystem->symlink($originDir, $targetDir);
119+
$output->writeln('It looks like your system doesn\'t support relative symbolic links, so the assets were installed by using absolute symbolic links.');
120+
} catch (IOException $e) {
121+
$this->hardCopy($originDir, $targetDir);
122+
$output->writeln('It looks like your system doesn\'t support symbolic links, so the assets were installed by copying them.');
123+
}
110124
}
111125
} else {
112126
$this->hardCopy($originDir, $targetDir);

0 commit comments

Comments
 (0)