Skip to content

Commit

Permalink
Improve error handling and output messages display.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Dec 20, 2014
1 parent 55a5bfd commit ee68483
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions src/Shell/Task/AssetsTask.php
Expand Up @@ -60,42 +60,51 @@ protected function _process() {

$link = Inflector::underscore($plugin);
$dir = WWW_ROOT;
if (file_exists($dir . $link)) {
$this->out($link . ' already exists');
$this->out();
continue;
}

if (strpos('/', $link) !== false) {
$parts = explode('/', $link);
$link = array_pop($parts);
$dir = WWW_ROOT . implode(DS, $parts) . DS;
if (!is_dir($dir)) {
$this->out('Creating directory: ' . $dir);
$this->out();
$old = umask(0);
mkdir($dir, 0755, true);
// @codingStandardsIgnoreStart
$result = @mkdir($dir, 0755, true);
// @codingStandardsIgnoreEnd
umask($old);

if ($result) {
$this->out('Created directory ' . $dir);
} else {
$this->err('Failed creating directory ' . $dir);
continue;
}
}
}

$this->out('Creating symlink: ' . $dir);
$this->out();
if (file_exists($dir . $link)) {
$this->out($link . ' already exists', 1, Shell::VERBOSE);
continue;
}

// @codingStandardsIgnoreStart
$result = @symlink($path, $dir . $link);
// @codingStandardsIgnoreEnd

if (!$result) {
$this->err('Symlink creation failed');
$this->out('Copying to directory:' . $dir);
$this->out();
$folder = new Folder($path);
$folder->copy(['to' => $dir . $link]);
if ($result) {
$this->out('Created symlink ' . $dir . $link);
continue;
}

$folder = new Folder($path);
if ($folder->copy(['to' => $dir . $link])) {
$this->out('Copied assets to directory ' . $dir);
} else {
$this->err('Error copying assets to directory ' . $dir);
}
}

$this->out();
$this->out('Done.');
$this->out('Done');
}

}

0 comments on commit ee68483

Please sign in to comment.