Skip to content

Commit

Permalink
Fixed problem with "preview" command: regeneration was erratic
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed May 15, 2014
1 parent 9ebcd96 commit 0266b04
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/CLI/PreviewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// Generate the website
$generator = new Generator();
$generator->generate($config, $sourceDirectory, $targetDirectory, $output);
$lastCheckDate = date('Y-m-d H:i:s');
$lastGenerationDate = date('Y-m-d H:i:s');

// Start the webserver
$builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address')));
Expand All @@ -81,12 +81,13 @@ protected function execute(InputInterface $input, OutputInterface $output)

// Watch for changes
while (true) {
if ($this->hasChanges($sourceDirectory, $lastCheckDate, $generator, $output)) {
if ($this->hasChanges($sourceDirectory, $lastGenerationDate)) {
$output->writeln('');
$output->writeln('<info>File changes detected, regenerating</info>');
$lastGenerationDate = date('Y-m-d H:i:s');
$generator->generate($config, $sourceDirectory, $targetDirectory, $output);
}

$lastCheckDate = date('Y-m-d H:i:s');
sleep(1);
}
}
Expand Down

0 comments on commit 0266b04

Please sign in to comment.