Skip to content

Commit

Permalink
Issue #5 new config to choose which elements should be synced in a th…
Browse files Browse the repository at this point in the history
…emesync
  • Loading branch information
mrkmiller committed Feb 21, 2019
1 parent ae593b9 commit e831805
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
5 changes: 4 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@

The Theme Sync configuration for migrating source files to another project. Once migrated they need to be compiled into dev or production code for that project.

* __enabled__ - (Boolean) value to turn enable "themesync" Gulp task.
* __enabled__ - (Boolean) value to enable "themesync" Gulp task.
* __newsite__ - (Boolean) value to enable a gulp task `gulp newsite` for cloning a starterkit into a new project. Requires a `/starterkit/` directory is available such as [https://bitbucket.org/ietwebdev/sitefarm-pattern-lab-one/src/master/starterkit/](https://bitbucket.org/ietwebdev/sitefarm-pattern-lab-one/src/master/starterkit/)
* __src__ - (Boolean) False if exporting, or a file path to the source if importing.
* __dest__ - Path to the theme directory or new site. Make sure the path ends in a /.
* __sassSync__ - (Boolean) Set to True (default) if the `sass` directories should be synced.
* __sassSrc__ - Path to find the SASS.
* __sassDest__ - Path to place the SASS in destination.
* __jsSync__ - (Boolean) Set to True (default) if the `js` directories should be synced.
* __jsSrc__ - Path to find the JavaScript.
* __jsDest__ - Path to place the JavaScript in destination.
* __imagesSync__ - (Boolean) Set to True (default) if the `images` directories should be synced.
* __imagesSrc__ - Path to find the images.
* __imagesDest__ - Path to place the images in destination.

Expand Down
3 changes: 3 additions & 0 deletions gulp-config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ module.exports = {
newsite: false,
src: false,
dest: '../theme/',
sassSync: true,
sassSrc: 'source/sass/',
sassDest: 'sass/1_pattern_lab/',
jsSync: true,
jsSrc: 'source/js/',
jsDest: 'js/1_pattern_lab/',
imagesSync: true,
imagesSrc: 'source/images/',
imagesDest: 'images/'
},
Expand Down
31 changes: 20 additions & 11 deletions gulp_tasks/theme-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,32 @@ module.exports = function (gulp, config, tasks) {
}

// Delete and replace the Sass directory.
del(sassDest, {force: true}).then(() => {
copy(sassSrc, sassDest, {overwrite: true}).catch(function(error) {
console.error('Sass directory Copy failed: ' + error);
if (config.themeSync.sassSync) {
del(sassDest, {force: true}).then(() => {
copy(sassSrc, sassDest, {overwrite: true}).catch(function (error) {
console.error('Sass directory Copy failed: ' + error);
});
});
});
}

// Delete and replace the Js directory.
del(jsDest, {force: true}).then(() => {
copy(jsSrc, jsDest, {overwrite: true}).catch(function(error) {
console.error('Sass directory Copy failed: ' + error);
if (config.themeSync.jsSync) {
del(jsDest, {force: true}).then(() => {
copy(jsSrc, jsDest, {overwrite: true}).catch(function (error) {
console.error('Sass directory Copy failed: ' + error);
});
});
});
}

// Copy Images directory (but don't delete the directory first).
copy(imagesSrc, imagesDest, {overwrite: true, filter: ['**/*', '!sample/**/*', '!sample' ]}).catch(function(error) {
console.error('Images directory Copy failed: ' + error);
});
if (config.themeSync.imagesSync) {
copy(imagesSrc, imagesDest, {
overwrite: true,
filter: ['**/*', '!sample/**/*', '!sample'],
}).catch(function (error) {
console.error('Images directory Copy failed: ' + error);
});
}

});

Expand Down

0 comments on commit e831805

Please sign in to comment.