Skip to content

Commit d8711e7

Browse files
committed
Introduce postInstallMirrorTwitterBootstrap scripts
1 parent 2ad9c53 commit d8711e7

File tree

2 files changed

+68
-4
lines changed

2 files changed

+68
-4
lines changed

Command/BaseBootstrapSymlinkCommand.php

+22-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4444
$cmanager = new ComposerPathFinder($composer);
4545
$options = array(
4646
'targetSuffix' => DIRECTORY_SEPARATOR . "Resources" . DIRECTORY_SEPARATOR . static::$targetSuffix,
47-
'sourcePrefix' => '..' . DIRECTORY_SEPARATOR
47+
'sourcePrefix' => '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR
4848
);
4949
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
5050
self::$mopaBootstrapBundleName,
@@ -67,9 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
$this->output->writeln(" ... <comment>not existing</comment>");
6868
$this->output->writeln("Mirroring from: " . $symlinkName);
6969
$this->output->write("for Target: " . $symlinkTarget);
70-
71-
$filesystem = new Filesystem();
72-
$filesystem->mirror($symlinkTarget, $symlinkName, null, array('copy_on_windows' => true, 'delete' => true, 'override' => true));
70+
self::createMirror($symlinkTarget, $symlinkName);
7371
}
7472
} else {
7573
$this->output->write("Checking Symlink");
@@ -203,4 +201,24 @@ public static function createSymlink($symlinkTarget, $symlinkName)
203201
throw new \Exception("Symlink $symlinkName points to target $target");
204202
}
205203
}
204+
205+
/**
206+
* Create the mirror
207+
*
208+
* @param string $symlinkTarget The Target
209+
* @param string $symlinkName The Name
210+
*
211+
* @throws \Exception
212+
*/
213+
public static function createMirror($symlinkTarget, $symlinkName)
214+
{
215+
$filesystem = new Filesystem();
216+
$filesystem->mkdir($symlinkName);
217+
$filesystem->mirror(
218+
realpath($symlinkName . DIRECTORY_SEPARATOR . $symlinkTarget),
219+
$symlinkName,
220+
null,
221+
array('copy_on_windows' => true, 'delete' => true, 'override' => true)
222+
);
223+
}
206224
}

Composer/ScriptHandler.php

+46
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@ public static function postInstallSymlinkTwitterBootstrap(Event $event)
3737
$IO->write(" ... <info>OK</info>");
3838
}
3939

40+
public static function postInstallMirrorTwitterBootstrap(Event $event)
41+
{
42+
$IO = $event->getIO();
43+
$composer = $event->getComposer();
44+
$cmanager = new ComposerPathFinder($composer);
45+
$options = array(
46+
'targetSuffix' => DIRECTORY_SEPARATOR . "Resources" . DIRECTORY_SEPARATOR . "bootstrap",
47+
'sourcePrefix' => '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR
48+
);
49+
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
50+
BootstrapSymlinkLessCommand::$mopaBootstrapBundleName,
51+
BootstrapSymlinkLessCommand::$twitterBootstrapName,
52+
$options
53+
);
54+
55+
$IO->write("Checking Mirror", FALSE);
56+
if (false === BootstrapSymlinkLessCommand::checkSymlink($symlinkTarget, $symlinkName)) {
57+
$IO->write("Creating Mirror: " . $symlinkName, FALSE);
58+
BootstrapSymlinkLessCommand::createMirror($symlinkTarget, $symlinkName);
59+
}
60+
$IO->write(" ... <info>OK</info>");
61+
}
62+
4063
public static function postInstallSymlinkTwitterBootstrapSass(Event $event)
4164
{
4265
$IO = $event->getIO();
@@ -59,4 +82,27 @@ public static function postInstallSymlinkTwitterBootstrapSass(Event $event)
5982
}
6083
$IO->write(" ... <info>OK</info>");
6184
}
85+
86+
public static function postInstallMirrorTwitterBootstrapSass(Event $event)
87+
{
88+
$IO = $event->getIO();
89+
$composer = $event->getComposer();
90+
$cmanager = new ComposerPathFinder($composer);
91+
$options = array(
92+
'targetSuffix' => DIRECTORY_SEPARATOR . "Resources" . DIRECTORY_SEPARATOR . "bootstrap-sass",
93+
'sourcePrefix' => '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR
94+
);
95+
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
96+
BootstrapSymlinkSassCommand::$mopaBootstrapBundleName,
97+
BootstrapSymlinkSassCommand::$twitterBootstrapName,
98+
$options
99+
);
100+
101+
$IO->write("Checking Mirror", FALSE);
102+
if (false === BootstrapSymlinkSassCommand::checkSymlink($symlinkTarget, $symlinkName)) {
103+
$IO->write(" ... Creating Mirror: " . $symlinkName, FALSE);
104+
BootstrapSymlinkSassCommand::createMirror($symlinkTarget, $symlinkName);
105+
}
106+
$IO->write(" ... <info>OK</info>");
107+
}
62108
}

0 commit comments

Comments
 (0)