Skip to content

Commit 2968b4b

Browse files
committed
Added gulpfile.js
1 parent 0eedd04 commit 2968b4b

File tree

2 files changed

+119
-1
lines changed

2 files changed

+119
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package.json
2-
gulpfile.js
32
node_modules
43
.npm-debug.log
54
tmp

gulpfile.js

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
var gulp = require('gulp'),
2+
uglify = require('gulp-uglify'),
3+
rename = require('gulp-rename'),
4+
header = require('gulp-header'),
5+
bump = require('gulp-bump'),
6+
prefix = require('gulp-autoprefixer');
7+
8+
var pkg = require('./package.json');
9+
10+
gulp.task('js', function(){
11+
var banner = [
12+
'/*!',
13+
' * ,/',
14+
' * ,\'/',
15+
' * ,\' /',
16+
' * ,\' /_____,',
17+
' * .\'____ ,\'',
18+
' * / ,\'',
19+
' * / ,\'',
20+
' * /,\'',
21+
' * /\'',
22+
' *',
23+
' * Selectric \u03DE v<%= pkg.version %> (<%= new Date().toJSON().slice(0,10) %>) - http://lcdsantos.github.io/jQuery-Selectric/',
24+
' *',
25+
' * Copyright (c) <%= new Date().getFullYear() %> Leonardo Santos; Dual licensed: MIT\/GPL',
26+
' *',
27+
' */\n\n'
28+
].join('\n');
29+
30+
gulp.src('src/jquery.selectric.js')
31+
.pipe(header(banner, { pkg: pkg }))
32+
.pipe(gulp.dest('./dist'));
33+
});
34+
35+
gulp.task('js-min', function(){
36+
gulp.src('src/jquery.selectric.js')
37+
.pipe(uglify())
38+
.pipe(header('/*! Selectric ϟ v<%= pkg.version %> (<%= new Date().toJSON().slice(0,10) %>) - git.io/tjl9sQ - Copyright (c) <%= new Date().getFullYear() %> Leonardo Santos - Dual licensed: MIT/GPL */\n', { pkg: pkg }))
39+
.pipe(rename({
40+
suffix: '.min'
41+
}))
42+
.pipe(gulp.dest('./dist'));
43+
});
44+
45+
var sass = function(options){
46+
var through = require('through2'),
47+
gutil = require('gulp-util'),
48+
spawn = require('win-spawn'),
49+
exec = require('child_process').exec,
50+
path = require('path');
51+
52+
var options = options || {},
53+
style = options.style || 'expanded',
54+
sourcemap = options.sourcemap || 'none';
55+
56+
function changeFile(file, newExt, newContent, context, callback){
57+
file.path = gutil.replaceExtension( file.path, newExt );
58+
59+
file.contents = newContent;
60+
context.push(file);
61+
62+
callback();
63+
}
64+
65+
return through.obj(function(file, enc, cb) {
66+
var _this = this,
67+
args = ['--style', style, '--sourcemap=' + sourcemap, file.path];
68+
69+
if (file.isBuffer()) {
70+
exec(['sass'].concat(args).join(' '), function(error, stdout, stderr){
71+
72+
if ( stderr ){
73+
gutil.log('stderr: ' + stderr);
74+
}
75+
76+
if (error !== null) {
77+
gutil.log('exec error: ' + error);
78+
}
79+
80+
changeFile(file, '.css', new Buffer(stdout), _this, cb);
81+
});
82+
}
83+
84+
if (file.isStream()) {
85+
var cmd = spawn('sass', args);
86+
87+
cmd.stdout.on('data', function (data) {
88+
changeFile(file, '.css', data, _this, cb);
89+
});
90+
91+
cmd.stderr.setEncoding('utf8');
92+
cmd.stderr.on('data', function (data) {
93+
gutil.log(data);
94+
});
95+
}
96+
});
97+
}
98+
99+
module.exports = sass;
100+
101+
gulp.task('css', function(){
102+
gulp.src('./src/*.scss')
103+
.pipe(sass())
104+
.pipe(prefix('last 2 versions', '> 1%', 'ie 8', 'ie 7'))
105+
.pipe(gulp.dest('./dist'));
106+
});
107+
108+
gulp.task('bump', function(){
109+
var gutil = require('gulp-util'),
110+
newVersion = gutil.env.bump || pkg.version;
111+
112+
gulp.src(['./package.json', './bower.json', './selectric.jquery.json'])
113+
.pipe(bump({
114+
version: newVersion
115+
}))
116+
.pipe(gulp.dest('./'));
117+
});
118+
119+
gulp.task('default', ['js', 'js-min', 'css', 'bump']);

0 commit comments

Comments
 (0)