Skip to content
Snippets Groups Projects
Commit 45ae46ef authored by jurgenhaas's avatar jurgenhaas
Browse files

#7 Dynamically build gitignore file

parent d89e16e8
No related branches found
No related tags found
No related merge requests found
......@@ -209,6 +209,8 @@ class Handler
'templates/README.md',
'README.md',
'{{ project_name }}.starterkit.yml',
'.gitignore',
'.gitkeep',
]);
}
......@@ -296,6 +298,8 @@ class Handler
* @param string $destination
*/
protected function copyFiles($fs, $finder, $source, $destination) {
$files = [];
// Make sure all directories do exist
$finder->directories()->in($source);
foreach ($finder as $file) {
......@@ -331,7 +335,10 @@ class Handler
} else {
file_put_contents($filename, $this->twig(file_get_contents($file->getRealPath())));
}
$files[] = $tweakedRelFilename;
}
return $files;
}
/**
......@@ -344,37 +351,37 @@ class Handler
$fs = new Filesystem();
$destination = $this->getInstallationPath();
// We only do the fancy stuff for developers
if ($event->isDevMode()) {
$pluginRoot = $this->getInstallationManager()
->getInstallPath($this->getPackage('lakedrops/theme-d8-sass'));
$finder = new Finder();
$finder->ignoreDotFiles(FALSE);
// Copy all files
$this->copyFiles($fs, $finder, $pluginRoot . '/templates', $destination);
// Handle optional base theme
$baseTheme = $this->getOption('base_theme');
if (isset($baseTheme['package'])) {
$baseThemePackage = $this->getPackage($baseTheme['package']);
if ($baseThemePackage && isset($baseTheme['starterkit'])) {
$starterkitRoot = $this->getInstallationManager()->getInstallPath($baseThemePackage) . DIRECTORY_SEPARATOR . $baseTheme['starterkit'];
$this->copyFiles($fs, $finder, $starterkitRoot , $destination);
}
$pluginRoot = $this->getInstallationManager()
->getInstallPath($this->getPackage('lakedrops/theme-d8-sass'));
$finder = new Finder();
$finder->ignoreDotFiles(FALSE);
// Copy all files
$this->copyFiles($fs, $finder, $pluginRoot . '/templates', $destination);
// Handle optional base theme
$baseTheme = $this->getOption('base_theme');
if (isset($baseTheme['package'])) {
$baseThemePackage = $this->getPackage($baseTheme['package']);
if ($baseThemePackage && isset($baseTheme['starterkit'])) {
$starterkitRoot = $this->getInstallationManager()->getInstallPath($baseThemePackage) . DIRECTORY_SEPARATOR . $baseTheme['starterkit'];
$this->options['base_theme_files'] = $this->copyFiles($fs, $finder, $starterkitRoot , $destination);
}
}
// Remove bower stuff if that's available globally
if (empty($this->getOption('bower_assets')['dependencies'])) {
if ($fs->exists($destination . DIRECTORY_SEPARATOR . 'bower.json')) {
$fs->remove($destination . DIRECTORY_SEPARATOR . 'bower.json');
}
if ($fs->exists($destination . DIRECTORY_SEPARATOR . 'bower_components')) {
$fs->remove($destination . DIRECTORY_SEPARATOR . 'bower_components');
}
// Remove bower stuff if that's available globally
if (empty($this->getOption('bower_assets')['dependencies'])) {
if ($fs->exists($destination . DIRECTORY_SEPARATOR . 'bower.json')) {
$fs->remove($destination . DIRECTORY_SEPARATOR . 'bower.json');
}
if ($fs->exists($destination . DIRECTORY_SEPARATOR . 'bower_components')) {
$fs->remove($destination . DIRECTORY_SEPARATOR . 'bower_components');
}
}
// Finally write .gitignore
file_put_contents($destination . DIRECTORY_SEPARATOR . '.gitignore', $this->twig(file_get_contents($pluginRoot . '/templates/.gitignore')));
// Prepare post processing
$currentDir = getcwd();
chdir($destination);
......
# Ignore certain directories
.sass-cache/
bower_components/
fonts/*
fonts/*/
node_modules/
# Ignore files that get compiled
style.css
*.map
# System settings - please do NOT change
.sass-cache/
css/
bower_components/
{% for name, package in bower_assets %}
{% if package.fonts is defined %}
fonts/{{ package.name }}
{% endif %}
{% endfor %}
{% for name, package in bower_assets %}
{% if package.js is defined %}
js/{{ package.name }}
{% endif %}
{% endfor %}
node_modules/
sass/_bower-assets.scss
sass/_settings.scss
{% for file in base_theme_files|default([]) %}
{{ file }}
{% endfor %}
# Add your own irgnore patterns below this line
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment