gulp-iconfont-css
Advanced tools
Comparing version
24
index.js
'use strict'; | ||
var path = require('path'), | ||
gutil = require('gulp-util'), | ||
Vinyl = require('vinyl'), | ||
PluginError = require('plugin-error'), | ||
consolidate = require('consolidate'), | ||
@@ -38,3 +39,3 @@ _ = require('lodash'), | ||
} | ||
if(/^(scss|less|css)$/i.test(config.path)) { | ||
if(/^(scss|sass|less|css)$/i.test(config.path)) { | ||
config.path = __dirname + '/templates/_icons.' + config.path; | ||
@@ -45,6 +46,6 @@ } | ||
if (!config.fontName) { | ||
throw new gutil.PluginError(PLUGIN_NAME, 'Missing option "fontName"'); | ||
throw new PluginError(PLUGIN_NAME, 'Missing option "fontName"'); | ||
} | ||
if (!consolidate[config.engine]) { | ||
throw new gutil.PluginError(PLUGIN_NAME, 'Consolidate missing template engine "' + config.engine + '"'); | ||
throw new PluginError(PLUGIN_NAME, 'Consolidate missing template engine "' + config.engine + '"'); | ||
} | ||
@@ -54,3 +55,3 @@ try { | ||
} catch(e) { | ||
throw new gutil.PluginError(PLUGIN_NAME, 'Template engine "' + config.engine + '" not present'); | ||
throw new PluginError(PLUGIN_NAME, 'Template engine "' + config.engine + '" not present'); | ||
} | ||
@@ -76,7 +77,7 @@ | ||
if (!outputFile) { | ||
outputFile = new gutil.File({ | ||
outputFile = new Vinyl({ | ||
base: file.base, | ||
cwd: file.cwd, | ||
path: path.join(file.base, config.targetPath), | ||
contents: file.isBuffer() ? new Buffer(0) : new Stream.PassThrough() | ||
contents: file.isBuffer() ? Buffer.alloc(0) : new Stream.PassThrough() | ||
}); | ||
@@ -130,11 +131,6 @@ } | ||
if (err) { | ||
throw new gutil.PluginError(PLUGIN_NAME, 'Error in template: ' + err.message); | ||
throw new PluginError(PLUGIN_NAME, 'Error in template: ' + err.message); | ||
} | ||
// TODO: remove condition and the else block for version 3.0 | ||
if( Buffer.from ){ | ||
content = Buffer.from(html); | ||
}else{ | ||
content = Buffer(html); | ||
} | ||
content = Buffer.from(html); | ||
@@ -141,0 +137,0 @@ if (outputFile.isBuffer()) { |
{ | ||
"name": "gulp-iconfont-css", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"description": "Generate (S)CSS file for icon font created with Gulp", | ||
@@ -9,3 +9,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=6" | ||
}, | ||
@@ -25,14 +25,15 @@ "scripts": { | ||
"dependencies": { | ||
"gulp-util": "^3.0.6", | ||
"consolidate": "^0.13.1", | ||
"lodash": "^3.10.0" | ||
"consolidate": "^0.15.1", | ||
"lodash": "^4.17.11", | ||
"plugin-error": "^1.0.1", | ||
"vinyl": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"del": "^2.2.0", | ||
"event-stream": "^3.3.1", | ||
"gulp": "^3.9.0", | ||
"gulp-iconfont": "^5.0.0", | ||
"mocha": "*", | ||
"del": "^3.0.0", | ||
"event-stream": "3.3.4", | ||
"gulp": "^4.0.0", | ||
"gulp-iconfont": "^10.0.2", | ||
"mocha": "^5.2.0", | ||
"object-assign": "^4.0.1" | ||
} | ||
} |
@@ -7,3 +7,2 @@ # gulp-iconfont-css | ||
Recent versions of [gulp-iconfont](https://github.com/nfroidure/gulp-iconfont) emit a `glyphs` (or `codepoints` < 4.0.0) event (see [docs](https://github.com/nfroidure/gulp-iconfont/)) which should likely be used instead of the workflow described below. However, it will continue to work as expected. | ||
The future of this plugin will be discussed in https://github.com/backflip/gulp-iconfont-css/issues/9. | ||
@@ -50,3 +49,3 @@ ## Usage | ||
The name of the generated font family (required). **Important**: Has to be identical to iconfont's ```fontName``` option. | ||
The name of the generated font family (required). **Important**: Has to be identical to iconfont's `fontName` option. | ||
@@ -56,3 +55,3 @@ #### options.path | ||
The template path (optional, defaults to `css` template provided with plugin).If set to `'scss'` or `'less'`, the corresponding default template will be used. See [templates](templates) | ||
The template path (optional, defaults to `css` template provided with plugin). If set to `scss`, `sass` or `less`, the corresponding default template will be used. See [templates](templates). | ||
@@ -62,3 +61,3 @@ #### options.targetPath | ||
The path where the (S)CSS file should be saved, relative to the path used in ```gulp.dest()``` (optional, defaults to ```_icons.css```). Depennding on the path, it might be necessary to set the ```base``` option, see https://github.com/backflip/gulp-iconfont-css/issues/16. | ||
The path where the (S)CSS file should be saved, relative to the path used in `gulp.dest()` (optional, defaults to `_icons.css`). Depennding on the path, it might be necessary to set the `base` option, see https://github.com/backflip/gulp-iconfont-css/issues/16. | ||
@@ -83,3 +82,3 @@ #### options.fontPath | ||
The template engine to use (optional, defaults to ```lodash```). | ||
The template engine to use (optional, defaults to `lodash`). | ||
See https://github.com/visionmedia/consolidate.js/ for available engines. The engine has to be installed before using. | ||
@@ -86,0 +85,0 @@ |
@@ -101,3 +101,3 @@ var gulp = require('gulp'), | ||
it('glyphs should start with custom code point', function(done) { | ||
var dest = resultsDir + '_codepoint_first'; | ||
var dest = resultsDir + '_codepoint_fixed'; | ||
@@ -147,2 +147,3 @@ run('css', dest, { | ||
testType('scss', 'SCSS'); | ||
testType('sass', 'Sass'); | ||
testType('less', 'Less'); | ||
@@ -149,0 +150,0 @@ testType('css', 'CSS'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
44290
5.9%36
9.09%4
33.33%395
-0.75%87
-1.14%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated