mirror of
https://github.com/pattern-lab/patternlab-php.git
synced 2025-01-17 14:18:30 +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);
|
$styleGuideHead = $this->mv->render($this->mainPageHead,$sd);
|
||||||
$styleGuideFoot = $this->mv->render($this->mainPageFoot,$sd);
|
$styleGuideFoot = $this->mv->render($this->mainPageFoot,$sd);
|
||||||
$styleGuidePage = $styleGuideHead.$this->mfs->render('viewall',$sd).$styleGuideFoot;
|
$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() {
|
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
|
// make sure the pattern header & footer are added
|
||||||
$this->addPatternHF = true;
|
$this->addPatternHF = true;
|
||||||
|
|
||||||
@ -1172,21 +1182,25 @@ class Builder {
|
|||||||
*/
|
*/
|
||||||
protected function cleanPublic() {
|
protected function cleanPublic() {
|
||||||
|
|
||||||
// find all of the patterns in public/. sort by the children first
|
// make sure patterns exists before trying to clean it
|
||||||
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->pd."/patterns/"), \RecursiveIteratorIterator::CHILD_FIRST);
|
if (is_dir($this->pd."/patterns")) {
|
||||||
|
|
||||||
// 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()) {
|
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->pd."/patterns/"), \RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
// if this is a directory remove it
|
|
||||||
rmdir($name);
|
// make sure dots are skipped
|
||||||
} else if ($object->isFile() && ($object->getFilename() != "README")) {
|
$objects->setFlags(\FilesystemIterator::SKIP_DOTS);
|
||||||
// if this is a file remove it
|
|
||||||
unlink($name);
|
// 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
|
// render out the index and style guide
|
||||||
$this->generateMainPages();
|
$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
|
// 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);
|
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd."/_data/"), \RecursiveIteratorIterator::SELF_FIRST);
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ class Migrator {
|
|||||||
|
|
||||||
if (!is_dir($destinationPath)) {
|
if (!is_dir($destinationPath)) {
|
||||||
mkdir($destinationPath);
|
mkdir($destinationPath);
|
||||||
$this->runMigration($filename, $sourcePath, $destinationPath, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ($checkType == "fileExists") {
|
} else if ($checkType == "fileExists") {
|
||||||
@ -70,6 +69,11 @@ class Migrator {
|
|||||||
|
|
||||||
} else if (($checkType == "versionDiffDir") && $diffVersion) {
|
} else if (($checkType == "versionDiffDir") && $diffVersion) {
|
||||||
|
|
||||||
|
// make sure the destination path exists
|
||||||
|
if (!is_dir($destinationPath)) {
|
||||||
|
mkdir($destinationPath);
|
||||||
|
}
|
||||||
|
|
||||||
$this->runMigration($filename, $sourcePath, $destinationPath, false);
|
$this->runMigration($filename, $sourcePath, $destinationPath, false);
|
||||||
|
|
||||||
} else if (($checkType == "versionDiffFile") && $diffVersion) {
|
} else if (($checkType == "versionDiffFile") && $diffVersion) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user