Browse Source

#1645 Fix default component inheritance from defaults

pull/1623/merge
jlukic 9 years ago
parent
commit
de4fef91e0
1 changed files with 18 additions and 8 deletions
  1. 26
      gulpfile.js

26
gulpfile.js

@ -118,7 +118,9 @@ var
runSetup = true; runSetup = true;
config = defaults; config = defaults;
} }
config = extend(true, {}, defaults, config);
// extend defaults using shallow copy
config = extend(false, {}, defaults, config);
// shorthand // shorthand
base = config.base; base = config.base;
@ -126,6 +128,7 @@ var
output = config.paths.output; output = config.paths.output;
source = config.paths.source; source = config.paths.source;
// npm package.json holds true "version"
version = (package !== undefined) version = (package !== undefined)
? package.version || 'Unknown' ? package.version || 'Unknown'
: 'Unknown' : 'Unknown'
@ -139,14 +142,14 @@ var
: '{' + defaults.components.join(',') + '}' : '{' + defaults.components.join(',') + '}'
; ;
// relative paths
// relative asset paths for css
assetPaths = { assetPaths = {
uncompressed : path.relative(output.uncompressed, output.themes).replace(/\\/g,'/'), uncompressed : path.relative(output.uncompressed, output.themes).replace(/\\/g,'/'),
compressed : path.relative(output.compressed, output.themes).replace(/\\/g,'/'), compressed : path.relative(output.compressed, output.themes).replace(/\\/g,'/'),
packaged : path.relative(output.packaged, output.themes).replace(/\\/g,'/') packaged : path.relative(output.packaged, output.themes).replace(/\\/g,'/')
}; };
// add base to values
// add base path to all folders
for(var folder in source) { for(var folder in source) {
if(source.hasOwnProperty(folder)) { if(source.hasOwnProperty(folder)) {
source[folder] = path.normalize(base + source[folder]); source[folder] = path.normalize(base + source[folder]);
@ -163,6 +166,9 @@ var
getConfigValues(); getConfigValues();
console.log(config);
return;
/******************************* /*******************************
Tasks Tasks
@ -177,11 +183,13 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb
console.clear(); console.clear();
console.log('Watching source files for changes'); console.log('Watching source files for changes');
if(!fs.existsSync(config.files.theme)) { if(!fs.existsSync(config.files.theme)) {
console.error('Cant compile LESS. Run "gulp install" to create a theme config file'); console.error('Cant compile LESS. Run "gulp install" to create a theme config file');
return; return;
} }
// start rtl task instead
if(config.rtl) { if(config.rtl) {
gulp.start('watch rtl'); gulp.start('watch rtl');
return; return;
@ -217,11 +225,13 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb
isConfig = (file.path.indexOf('.config') !== -1); isConfig = (file.path.indexOf('.config') !== -1);
if(isDefinition || isPackagedTheme || isSiteTheme) { if(isDefinition || isPackagedTheme || isSiteTheme) {
// rebuild only matching definition file
srcPath = util.replaceExtension(file.path, '.less'); srcPath = util.replaceExtension(file.path, '.less');
srcPath = srcPath.replace(config.regExp.themePath, source.definitions); srcPath = srcPath.replace(config.regExp.themePath, source.definitions);
srcPath = srcPath.replace(source.site, source.definitions); srcPath = srcPath.replace(source.site, source.definitions);
} }
else if(isConfig) { else if(isConfig) {
// impossible to tell which file was updated in theme.config, rebuild all
console.log('Change detected in theme config'); console.log('Change detected in theme config');
gulp.start('build'); gulp.start('build');
} }
@ -247,7 +257,7 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb
.pipe(autoprefixer(settings.prefix)) .pipe(autoprefixer(settings.prefix))
; ;
// use 2 concurrent streams from same source
// use 2 concurrent streams from same pipe
uncompressedStream = stream.pipe(clone()); uncompressedStream = stream.pipe(clone());
compressedStream = stream.pipe(clone()); compressedStream = stream.pipe(clone());
@ -287,7 +297,7 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb
}) })
; ;
// watch changes in assets
// watch for changes in assets
gulp gulp
.watch([ .watch([
source.themes + '**/assets/**' source.themes + '**/assets/**'
@ -301,7 +311,7 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb
}) })
; ;
// watch changes in js
// watch for changes in js
gulp gulp
.watch([ .watch([
source.definitions + '**/*.js' source.definitions + '**/*.js'
@ -342,14 +352,14 @@ gulp.task('build', 'Builds all files from source', function(callback) {
return; return;
} }
// Run RTL build instead
if(config.rtl) { if(config.rtl) {
gulp.start('build rtl'); gulp.start('build rtl');
return; return;
} }
// get relative asset path (path returns wrong path?)
// assetPaths.source = path.relative(srcPath, path.resolve(source.themes)); // assetPaths.source = path.relative(srcPath, path.resolve(source.themes));
assetPaths.source = '../../themes'; // hardcoded
assetPaths.source = '../../themes'; // path.relative returns wrong path (hardcoded for src)
// copy assets // copy assets
gulp.src(source.themes + '**/assets/**') gulp.src(source.themes + '**/assets/**')

Loading…
Cancel
Save