Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

[+] PROJECT: Gulp options #211

Merged
merged 3 commits into from
May 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var notify = require("gulp-notify");
var bourbon = require('node-bourbon');

var themeName = 'community-theme-16';
var gulpif = require('gulp-if');
var options = require('./package.json').options;

var createFolders = [
'./themes/' + themeName + '/cache/',
'./themes/' + themeName + '/pdf/',
'./themes/' + themeName + '/pdf/lang/'
'./themes/' + options.themeName + '/cache/',
'./themes/' + options.themeName + '/pdf/',
'./themes/' + options.themeName + '/pdf/lang/'
];

var copyIndexIgnore = [];

var cleanUp = [
'./themes/' + themeName + '/.sass-cache/',
'./themes/' + themeName + '/cache/*',
'./themes/' + themeName + '/css/**/*.css.map'
'./themes/' + options.themeName + '/.sass-cache/',
'./themes/' + options.themeName + '/cache/*',
'./themes/' + options.themeName + '/css/**/*.css.map'
];

gulp.task('create-folders', function(callback){
Expand Down Expand Up @@ -56,7 +56,7 @@ function displayNotification(msg){
}

gulp.task('compile-css', function(){
return gulp.src('./themes/' + themeName + '/sass/**/*.scss')
return gulp.src('./themes/' + options.themeName + '/sass/**/*.scss')
.pipe(sass({
includePaths: bourbon.includePaths,
outputStyle: 'expanded',
Expand All @@ -65,14 +65,14 @@ gulp.task('compile-css', function(){
.on('error', function() {
displayNotification(sass.logError);
}))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./themes/' + themeName + '/css/'))
.pipe(displayNotification({ message: 'Compilation successful', onLast: true }));
.pipe(gulpif(options.sourcemaps, sourcemaps.init()))
.pipe(gulpif(options.sourcemaps, sourcemaps.write('./')))
.pipe(gulp.dest('./themes/' + options.themeName + '/css/'))
.pipe(displayNotification({ message: 'Compilation successful for ' + options.themeName, onLast: true }));
});

gulp.task('sass:watch', function () {
gulp.watch('./themes/' + themeName + '/sass/**/*.scss', ['compile-css']);
gulp.watch('./themes/' + options.themeName + '/sass/**/*.scss', ['compile-css']);
});

gulp.task('clean-up', function(){
Expand All @@ -84,7 +84,7 @@ gulp.task('clean-up', function(){
gulp.task('copy-index', function(callback){
var total;
var done = 0;
glob(['themes/' + themeName + '/**/', 'modules/*/**/'], { ignore : copyIndexIgnore }, function(err, folders) {
glob(['themes/' + options.themeName + '/**/', 'modules/*/**/'], { ignore : copyIndexIgnore }, function(err, folders) {
total = folders.length;
if (total < 1 && callback) {
callback();
Expand All @@ -109,10 +109,10 @@ gulp.task('copy-index', function(callback){
gulp.task('format-js', function () {

return gulp.src([
'./themes*/' + themeName + '/js/**/*.js',
'!./themes*/' + themeName + '/js/**/*.min.js',
'!./themes*/' + themeName + '/js/autoload/**/*.js',
'!./themes*/' + themeName + '/js/debug/**/*.js'
'./themes*/' + options.themeName + '/js/**/*.js',
'!./themes*/' + options.themeName + '/js/**/*.min.js',
'!./themes*/' + options.themeName + '/js/autoload/**/*.js',
'!./themes*/' + options.themeName + '/js/debug/**/*.js'
])
.pipe(jscs({ fix : true }))
.pipe(gulp.dest('./'));
Expand All @@ -133,11 +133,11 @@ gulp.task('create-zip', function(){
}

return gulp.src([
'./themes*/' + themeName + '*/**',
'./themes*/' + options.themeName + '*/**',
'./modules*/ct*/**',
'./Config.xml'
])
.pipe(zip('v' + themeVersion + '-' + themeName + '.zip'))
.pipe(zip('v' + themeVersion + '-' + options.themeName + '.zip'))
.pipe(gulp.dest('./'));
});
});
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"node-bourbon": "^4.2.8",
"mkdirp": "^0.5.1",
"run-sequence": "^1.1.5",
"gulp-notify": "^2.2.0"
"gulp-notify": "^2.2.0",
"gulp-if": "^2.0.1"
},
"options": {
"themeName": "community-theme-16",
"sourcemaps": false
}
}