Skip to content

Commit

Permalink
#1645 Fix default component inheritance from defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Jan 16, 2015
1 parent a9a64ca commit de4fef9
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,17 @@ var
runSetup = true;
config = defaults;
}
config = extend(true, {}, defaults, config);

// extend defaults using shallow copy
config = extend(false, {}, defaults, config);

// shorthand
base = config.base;
clean = config.paths.clean;
output = config.paths.output;
source = config.paths.source;

// npm package.json holds true "version"
version = (package !== undefined)
? package.version || 'Unknown'
: 'Unknown'
Expand All @@ -139,14 +142,14 @@ var
: '{' + defaults.components.join(',') + '}'
;

// relative paths
// relative asset paths for css
assetPaths = {
uncompressed : path.relative(output.uncompressed, output.themes).replace(/\\/g,'/'),
compressed : path.relative(output.compressed, 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) {
if(source.hasOwnProperty(folder)) {
source[folder] = path.normalize(base + source[folder]);
Expand All @@ -163,6 +166,9 @@ var

getConfigValues();

console.log(config);
return;


/*******************************
Tasks
Expand All @@ -177,11 +183,13 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb
console.clear();
console.log('Watching source files for changes');


if(!fs.existsSync(config.files.theme)) {
console.error('Cant compile LESS. Run "gulp install" to create a theme config file');
return;
}

// start rtl task instead
if(config.rtl) {
gulp.start('watch rtl');
return;
Expand Down Expand Up @@ -217,11 +225,13 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb
isConfig = (file.path.indexOf('.config') !== -1);

if(isDefinition || isPackagedTheme || isSiteTheme) {
// rebuild only matching definition file
srcPath = util.replaceExtension(file.path, '.less');
srcPath = srcPath.replace(config.regExp.themePath, source.definitions);
srcPath = srcPath.replace(source.site, source.definitions);
}
else if(isConfig) {
// impossible to tell which file was updated in theme.config, rebuild all
console.log('Change detected in theme config');
gulp.start('build');
}
Expand All @@ -247,7 +257,7 @@ gulp.task('watch', 'Watch for site/theme changes (Default Task)', function(callb
.pipe(autoprefixer(settings.prefix))
;

// use 2 concurrent streams from same source
// use 2 concurrent streams from same pipe
uncompressedStream = stream.pipe(clone());
compressedStream = stream.pipe(clone());

Expand Down Expand Up @@ -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
.watch([
source.themes + '**/assets/**'
Expand All @@ -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
.watch([
source.definitions + '**/*.js'
Expand Down Expand Up @@ -342,14 +352,14 @@ gulp.task('build', 'Builds all files from source', function(callback) {
return;
}

// Run RTL build instead
if(config.rtl) {
gulp.start('build rtl');
return;
}

// get relative asset path (path returns wrong path?)
// 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
gulp.src(source.themes + '**/assets/**')
Expand Down

0 comments on commit de4fef9

Please sign in to comment.