2016-01-18 05:20:08 +08:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var iconfont = require('gulp-iconfont');
|
|
|
|
var iconfontCss = require('gulp-iconfont-css');
|
|
|
|
|
2016-01-23 01:39:44 +08:00
|
|
|
String.prototype.toTitleCase = function() {
|
|
|
|
return this.replace(/\w\S*/g, function(txt){ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); });
|
|
|
|
};
|
|
|
|
|
2016-01-20 19:58:47 +08:00
|
|
|
String.prototype.toCamelCase = function() {
|
2016-01-23 01:39:44 +08:00
|
|
|
var str = this.split('--');
|
|
|
|
var result;
|
|
|
|
|
|
|
|
if (str && str.length > 1) {
|
|
|
|
result = str[0] + str[1].toTitleCase();
|
|
|
|
} else {
|
|
|
|
result = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result.replace(/^([A-Z])|\s(\w)/g, function(match, p1, p2, offset) {
|
2016-01-20 19:58:47 +08:00
|
|
|
if (p2) return p2.toUpperCase();
|
|
|
|
return p1.toLowerCase();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-01-18 05:20:08 +08:00
|
|
|
gulp.task('default', function(){
|
2016-01-18 23:31:43 +08:00
|
|
|
gulp.src(['./icon-font/svgs/*.svg'])
|
2016-01-18 05:20:08 +08:00
|
|
|
|
|
|
|
.pipe(iconfontCss({
|
|
|
|
fontName: 'cartoIcon',
|
2016-01-18 23:31:43 +08:00
|
|
|
path: './icon-font/template.jst.ejs',
|
2016-01-22 18:53:57 +08:00
|
|
|
targetPath: '../scss/cdb-icon-font.scss',
|
2016-01-18 05:20:08 +08:00
|
|
|
fontPath: '../../fonts/'
|
|
|
|
}))
|
|
|
|
|
|
|
|
.pipe(iconfont({
|
|
|
|
fontName: 'cartoIcon',
|
2016-01-18 23:31:43 +08:00
|
|
|
appendCodepoints: true
|
2016-01-18 05:20:08 +08:00
|
|
|
}))
|
|
|
|
|
|
|
|
.pipe(gulp.dest('src/fonts/'));
|
|
|
|
});
|