Skip to content

Commit

Permalink
Fixes #33.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Jun 11, 2016
1 parent 8ef6891 commit 9dec6f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
26 changes: 10 additions & 16 deletions src/Command/NewWebsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,17 @@ public function processCommand()
$this->wlAnnonce('Creates a new website...');
try {
$fs = new FS();
$root = '';
if (empty(\Phar::running())) {
$root = __DIR__.'/../../';
}
if (!$fs->exists($this->getPath().'/'.self::CONFIG_FILE) || $this->force) {
if (!empty(\Phar::running())) {
$phar = new \Phar(\Phar::running());
$phar->extractTo($this->getPath(), [
'skeleton/phpoole.yml',
'skeleton/content/',
'skeleton/layouts/',
'skeleton/static/',
'skeleton/themes/',
], true);
} else {
$fs->copy(__DIR__.'/../../skeleton/phpoole.yml', $this->getPath().'/'.self::CONFIG_FILE, true);
$fs->mirror(__DIR__.'/../../skeleton/content', $this->getPath().'/content');
$fs->mirror(__DIR__.'/../../skeleton/layouts', $this->getPath().'/layouts');
$fs->mirror(__DIR__.'/../../skeleton/static', $this->getPath().'/static');
$fs->mirror(__DIR__.'/../../skeleton/themes', $this->getPath().'/themes');
}
$fs->copy($root.'skeleton/phpoole.yml', $this->getPath().'/'.self::CONFIG_FILE, true);
$fs->mirror($root.'skeleton/content', $this->getPath().'/content');
$fs->mirror($root.'skeleton/layouts', $this->getPath().'/layouts');
$fs->mirror($root.'skeleton/static', $this->getPath().'/static');
$fs->mirror($root.'skeleton/themes', $this->getPath().'/themes');

$this->wlDone('Done!');
} else {
$this->wlAlert(sprintf('File "%s" already exists.', $this->getPath().'/'.self::CONFIG_FILE));
Expand Down
15 changes: 6 additions & 9 deletions src/Command/Serve.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,16 @@ public function processCommand()

try {
$fs = new FS();
if (!empty(\Phar::running())) {
$phar = new \Phar(\Phar::running());
$phar->extractTo($this->getPath(), [
'skeleton/.router.php',
'skeleton/.watch.js',
], true);
} else {
$fs->copy(__DIR__.'/../../skeleton/.router.php', $this->getPath().'/.router.php', true);
$fs->copy(__DIR__.'/../../skeleton/.watch.js', $this->getPath().'/.watch.js', true);
$root = '';
if (empty(\Phar::running())) {
$root = __DIR__.'/../../';
}
$fs->copy($root.'skeleton/.router.php', $this->getPath().'/.router.php', true);
$fs->copy($root.'skeleton/.watch.js', $this->getPath().'/.watch.js', true);
$fs->dumpFile($this->getPath().'/.baseurl', $this->getPHPoole()->getOption('site.baseurl'));
} catch (IOExceptionInterface $e) {
echo 'An error occurred while copying file at '.$e->getPath();
echo PHP_EOL.$e->getMessage();
exit(2);
}
if (!is_file(sprintf('%s/.router.php', $this->getPath()))) {
Expand Down

0 comments on commit 9dec6f1

Please sign in to comment.