Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Performance improvements.
  Check for themes before running.
  • Loading branch information
Jelle-S committed Feb 16, 2017
2 parents 8a5d741 + 14f3274 commit 62a27b2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 35 deletions.
56 changes: 22 additions & 34 deletions src/PackageDrupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,33 @@ class PackageDrupal8 extends PackageProject
/**
* {@inheritdoc}
*/
protected function getFiles()
protected function cleanMirrorDir()
{
$dir = $this->dir;
if (is_null($dir)) {
$projectRoot = $this->getConfig()->get('digipolis.root.project', null);
$dir = is_null($projectRoot)
? getcwd()
: $projectRoot;
// Only keep web, vendor and config folder.
$folders = new Finder();
$folders->in($this->tmpDir);
$folders->depth(0);
$folders->notPath('/^(web|vendor|config)$/');
$this->fs->remove($folders);

if (empty($this->ignoreFileNames)) {
return;
}
$finder = new Finder();
$finder->ignoreDotFiles(false);
// Ignore dotfiles except .htaccess.
$finder->notPath('/(^|\/)\.(?!(htaccess$)).+(\/|$)/');
$files = new Finder();
$files->in($this->tmpDir);
$files->ignoreDotFiles(false);
$files->files();

$dotfiles = clone $files;

// Ignore other files defined by the dev.
// Ignore files defined by the dev.
foreach ($this->ignoreFileNames as $fileName) {
$finder->notName($fileName);
$files->name($fileName);
}
$dirs = [];
$finderClone = clone $finder;
$finder->in([
$dir . '/vendor',
$dir . '/web',
$dir . '/config',
]);
foreach ($finder as $file) {
$realPath = $file->getRealPath();
if (is_dir($realPath)) {
$subDirFinder = clone $finderClone;
// This is a directory that contains files that will be added.
// So don't add the directory or files will be added twice.
if ($subDirFinder->in($realPath)->files()->count()) {
continue;
}
}
$this->fs->remove($files);

$relative = substr($realPath, strlen($dir) + 1);
$dirs[$relative] = $realPath;
}
return $dirs;
// Remove dotfiles except .htaccess.
$dotfiles->path('/(^|\/)\.(?!(htaccess$)).+(\/|$)/');
$this->fs->remove($dotfiles);
}
}
4 changes: 3 additions & 1 deletion src/ThemesCleanDrupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public function run()
$themes = empty($this->themes)
? $themesFromConfig
: $this->themes;

if (!$themes) {
return \Robo\Result::success($this);
}
$collection = $this->collectionBuilder();
foreach ($this->getThemePaths($themes) as $path) {
$collection->addTask($this->taskThemeClean($path));
Expand Down
3 changes: 3 additions & 0 deletions src/ThemesCompileDrupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public function run()
$themes = empty($this->themes)
? $this->getConfig()->get('digipolis.themes.drupal8', false)
: $this->themes;
if (!$themes) {
return \Robo\Result::success($this);
}
$collection = $this->collectionBuilder();
foreach ($this->getThemePaths(array_keys($themes)) as $themeName => $path) {
$command = $themes[$themeName];
Expand Down

0 comments on commit 62a27b2

Please sign in to comment.