mirror of
https://github.com/pattern-lab/patternlab-php.git
synced 2025-01-17 06:08:23 +01:00
better handling of deleted files and folders
This commit is contained in:
parent
070f66c51a
commit
ea984c3445
@ -214,7 +214,12 @@ class Builder {
|
||||
$styleGuideHead = $this->mv->render($this->mainPageHead,$sd);
|
||||
$styleGuideFoot = $this->mv->render($this->mainPageFoot,$sd);
|
||||
$styleGuidePage = $styleGuideHead.$this->mfs->render('viewall',$sd).$styleGuideFoot;
|
||||
file_put_contents($this->pd."/styleguide/html/styleguide.html",$styleGuidePage);
|
||||
|
||||
if (!file_exists($this->pd."/styleguide/html/styleguide.html")) {
|
||||
print "ERROR: the main style guide wasn't written out. make sure public/styleguide exists. can copy core/styleguide\n";
|
||||
} else {
|
||||
file_put_contents($this->pd."/styleguide/html/styleguide.html",$styleGuidePage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -223,6 +228,11 @@ class Builder {
|
||||
*/
|
||||
protected function generatePatterns() {
|
||||
|
||||
// make sure patterns exists
|
||||
if (!is_dir($this->pd."/patterns")) {
|
||||
mkdir($this->pd."/patterns");
|
||||
}
|
||||
|
||||
// make sure the pattern header & footer are added
|
||||
$this->addPatternHF = true;
|
||||
|
||||
@ -1172,21 +1182,25 @@ class Builder {
|
||||
*/
|
||||
protected function cleanPublic() {
|
||||
|
||||
// find all of the patterns in public/. sort by the children first
|
||||
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->pd."/patterns/"), \RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
// make sure dots are skipped
|
||||
$objects->setFlags(\FilesystemIterator::SKIP_DOTS);
|
||||
|
||||
// for each file figure out what to do with it
|
||||
foreach($objects as $name => $object) {
|
||||
// make sure patterns exists before trying to clean it
|
||||
if (is_dir($this->pd."/patterns")) {
|
||||
|
||||
if ($object->isDir()) {
|
||||
// if this is a directory remove it
|
||||
rmdir($name);
|
||||
} else if ($object->isFile() && ($object->getFilename() != "README")) {
|
||||
// if this is a file remove it
|
||||
unlink($name);
|
||||
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->pd."/patterns/"), \RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
// make sure dots are skipped
|
||||
$objects->setFlags(\FilesystemIterator::SKIP_DOTS);
|
||||
|
||||
// for each file figure out what to do with it
|
||||
foreach($objects as $name => $object) {
|
||||
|
||||
if ($object->isDir()) {
|
||||
// if this is a directory remove it
|
||||
rmdir($name);
|
||||
} else if ($object->isFile() && ($object->getFilename() != "README")) {
|
||||
// if this is a file remove it
|
||||
unlink($name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,6 +71,11 @@ class Generator extends Builder {
|
||||
// render out the index and style guide
|
||||
$this->generateMainPages();
|
||||
|
||||
// make sure data exists
|
||||
if (!is_dir($this->pd."/data")) {
|
||||
mkdir($this->pd."/data");
|
||||
}
|
||||
|
||||
// iterate over the data files and regenerate the entire site if they've changed
|
||||
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd."/_data/"), \RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
|
@ -59,7 +59,6 @@ class Migrator {
|
||||
|
||||
if (!is_dir($destinationPath)) {
|
||||
mkdir($destinationPath);
|
||||
$this->runMigration($filename, $sourcePath, $destinationPath, false);
|
||||
}
|
||||
|
||||
} else if ($checkType == "fileExists") {
|
||||
@ -70,6 +69,11 @@ class Migrator {
|
||||
|
||||
} else if (($checkType == "versionDiffDir") && $diffVersion) {
|
||||
|
||||
// make sure the destination path exists
|
||||
if (!is_dir($destinationPath)) {
|
||||
mkdir($destinationPath);
|
||||
}
|
||||
|
||||
$this->runMigration($filename, $sourcePath, $destinationPath, false);
|
||||
|
||||
} else if (($checkType == "versionDiffFile") && $diffVersion) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user