Skip to content
Snippets Groups Projects
Commit 48c0100f authored by jurgenhaas's avatar jurgenhaas
Browse files

#7 Bug fixes

parent b3f782ef
No related branches found
No related tags found
No related merge requests found
......@@ -135,7 +135,7 @@ class Handler
$dependencies = [];
$to = $this->buildInstallationPath($this->options['project_name']);
foreach ($this->options['bower_assets'] as $key => $assets) {
foreach ($this->options['bower_assets'] as $key => $asset) {
$package = $this->getPackage('bower-asset/' . $key);
$version = $package ? $package->getVersion() : (isset($asset['version']) ? $asset['version'] : 'latest');
if ($package) {
......@@ -155,7 +155,7 @@ class Handler
$converter = new Converter($from, $to);
foreach (['fonts', 'sass', 'js'] as $type) {
if (isset($asset[$type])) {
$this->options['bower_assets'][$key][$type]['relative'] = $converter->convert($asset['src']);
$this->options['bower_assets'][$key][$type]['relative'] = $converter->convert($asset[$type]['src']);
}
}
}
......@@ -209,20 +209,24 @@ class Handler
];
}
protected function twig($string)
{
if (empty($string)) {
return '';
}
protected function tweaks($string) {
$string = str_replace('THEMENAME', '{{ project_name }}', $string);
$baseTheme = $this->getOption('base_theme');
if (isset($baseTheme['sasspath'])) {
if (strpos($baseTheme['sasspath'], $string) === 0) {
if (strpos($string, $baseTheme['sasspath']) === 0) {
$string = 'sass' . substr($string, strlen($baseTheme['sasspath']));
}
}
return $string;
}
protected function twig($string)
{
if (empty($string)) {
return '';
}
$this->twig_loader->setTemplate('fixed', $string);
$this->twig_loader->setTemplate('fixed', $this->tweaks($string));
return str_replace('"', '"', $this->twig->render('fixed', $this->getOptions()));
}
......@@ -292,19 +296,20 @@ class Handler
// Determine relative filename of destination
$relFilename = $file->getRelativePathname();
$tweakedRelFilename = $this->tweaks($relFilename);
$filename = $destination . DIRECTORY_SEPARATOR . $this->twig($relFilename);
// Do not copy ignored files
if (in_array($relFilename, $this->getIgnoredFiles())) {
if (in_array($tweakedRelFilename, $this->getIgnoredFiles())) {
continue;
}
// Do not update custom files
if ($fs->exists($filename) && in_array($relFilename, $this->getCustomFiles())) {
if ($fs->exists($filename) && in_array($tweakedRelFilename, $this->getCustomFiles())) {
continue;
}
// Now create destination
if (in_array($relFilename, $this->getBinaryFiles())) {
if (in_array($tweakedRelFilename, $this->getBinaryFiles())) {
$fs->copy($file->getRealPath(), $filename);
} else {
file_put_contents($filename, $this->twig(file_get_contents($file->getRealPath())));
......
......@@ -22,28 +22,28 @@ var gulp = require('gulp'),
{% for name, package in bower_assets %}
{% if package.fonts is defined %}
// Provide fonts from {{ name }}
gulp.task('fonts-{{ name }}', function() {
gulp.task('fonts-{{ package.name }}', function() {
return gulp.src('{{ package.fonts.relative }}/**.*')
.pipe(gulp.dest(config.fontsPath + '/{{ name }}'));
.pipe(gulp.dest(config.fontsPath + '/{{ package.name }}'));
});
{% endif %}
{% endfor %}
// Provide fonts from all libraries
gulp.task('fonts', [{% for name, package in bower_assets %}{% if package.fonts is defined %}'fonts-{{ name }}', {% endif %}{% endfor %}]);
gulp.task('fonts', [{% 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 %}
// Provide JS from {{ name }}
gulp.task('js-{{ name }}', function() {
gulp.task('js-{{ package.name }}', function() {
return gulp.src('{{ package.js.relative }}/**.*')
.pipe(gulp.dest(config.jsPath + '/{{ name }}'));
.pipe(gulp.dest(config.jsPath + '/{{ package.name }}'));
});
{% endif %}
{% endfor %}
// Provide JS from all libraries
gulp.task('js', [{% for name, package in bower_assets %}{% if package.js is defined %}'js-{{ name }}', {% endif %}{% endfor %}]);
gulp.task('js', [{% for name, package in bower_assets %}{% if package.js is defined %}'js-{{ package.name }}', {% endif %}{% endfor %}]);
// Pre-process CSS
gulp.task('css', function() {
......
{% for package, sass in bower_assets.sass %}
// ============== Using {{ package }}============================
{% for import in sass.import %}
{% for name, package in bower_assets %}
{% if package.sass is defined %}
// ============== Using {{ name }}============================
{% for import in package.sass.import %}
@import '{{ import }}';
{% endfor %}
{% endif %}
{% endfor %}
// ============== Using base theme {{ base_theme.package }}============================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment