Commit 67677dd7 by Alexander Makarov

Fixed build app/link to work on Windows

parent ff50f150
...@@ -23,6 +23,20 @@ class AppController extends Controller ...@@ -23,6 +23,20 @@ class AppController extends Controller
public $defaultAction = 'link'; public $defaultAction = 'link';
/** /**
* Properly removes symlinked directory under Windows, MacOS and Linux
*
* @param string $file path to symlink
*/
protected function unlink($file)
{
if (is_dir($file)) {
rmdir($file);
} else {
unlink($file);
}
}
/**
* This command runs the following shell commands in the dev repo root: * This command runs the following shell commands in the dev repo root:
* *
* - Run `composer update` * - Run `composer update`
...@@ -41,13 +55,13 @@ class AppController extends Controller ...@@ -41,13 +55,13 @@ class AppController extends Controller
// cleanup // cleanup
if (is_link($link = "$appDir/vendor/yiisoft/yii2")) { if (is_link($link = "$appDir/vendor/yiisoft/yii2")) {
$this->stdout("Removing symlink $link.\n"); $this->stdout("Removing symlink $link.\n");
unlink($link); $this->unlink($link);
} }
$extensions = $this->findDirs("$appDir/vendor/yiisoft"); $extensions = $this->findDirs("$appDir/vendor/yiisoft");
foreach($extensions as $ext) { foreach($extensions as $ext) {
if (is_link($link = "$appDir/vendor/yiisoft/yii2-$ext")) { if (is_link($link = "$appDir/vendor/yiisoft/yii2-$ext")) {
$this->stdout("Removing symlink $link.\n"); $this->stdout("Removing symlink $link.\n");
unlink($link); $this->unlink($link);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment