svgicons2svgfont
Advanced tools
Comparing version 3.0.2 to 3.0.3
{ | ||
"name": "svgicons2svgfont", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Read a set of SVG icons and ouput a SVG font", | ||
@@ -23,13 +23,18 @@ "homepage": "https://github.com/nfroidure/svgicons2svgfont", | ||
], | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
}, | ||
"dependencies": { | ||
"commander": "^2.8.1", | ||
"readable-stream": "^2.0.0", | ||
"sax": "1.1.x", | ||
"svg-pathdata": "1.0.0" | ||
"readable-stream": "^2.0.1", | ||
"sax": "^1.1.1", | ||
"string.fromcodepoint": "^0.2.1", | ||
"string.prototype.codepointat": "^0.2.0", | ||
"svg-pathdata": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "~2.11.2", | ||
"istanbul": "~0.3.15", | ||
"mocha": "~2.2.5", | ||
"mocha-lcov-reporter": "0.0.2", | ||
"coveralls": "^2.11.2", | ||
"istanbul": "^0.3.16", | ||
"mocha": "^2.2.5", | ||
"mocha-lcov-reporter": "^0.0.2", | ||
"streamtest": "^1.2.1" | ||
@@ -36,0 +41,0 @@ }, |
var fs = require('fs'); | ||
var util = require('util'); | ||
var path = require('path'); | ||
var fileSorter = require('./filesorter'); | ||
var Readable = require('stream').Readable; | ||
require('string.prototype.codepointat'); | ||
// Inherit of duplex stream | ||
@@ -31,25 +34,3 @@ util.inherits(SVGIconsDirStream, Readable); | ||
// Ensure prefixed files come first | ||
files = files.slice(0).sort(function(fileA, fileB) { | ||
var result = 0; | ||
if((/(^|\/)(?:((?:u[0-9a-f]{4,6},?)+)\-)(.+)\.svg$/i).test(fileA)) { | ||
if((/(^|\/)(?:((?:u[0-9a-f]{4,6},?)+)\-)(.+)\.svg$/i).test(fileB)) { | ||
if(fileA < fileB) { | ||
result = -1; | ||
} else { | ||
result = 1; | ||
} | ||
} else { | ||
result = -1; | ||
} | ||
} else { | ||
if((/(^|\/)(?:((?:u[0-9a-f]{4,6},?)+)\-)(.+)\.svg$/i).test(fileB)) { | ||
result = 1; | ||
} else if(fileA < fileB) { | ||
result = -1; | ||
} else { | ||
result = 1; | ||
} | ||
} | ||
return result; | ||
}); | ||
files = files.slice(0).sort(fileSorter); | ||
files.forEach(function(file) { | ||
@@ -63,3 +44,3 @@ getMetadata((dir ? dir + '/' : '') + file, function(err, metadata) { | ||
options.log('Saved codepoint: ' + | ||
'u' + metadata.unicode[0].charCodeAt(0).toString(16).toUpperCase() + | ||
'u' + metadata.unicode[0].codePointAt(0).toString(16).toUpperCase() + | ||
' for the glyph "' + metadata.name + '"'); | ||
@@ -66,0 +47,0 @@ } |
@@ -10,2 +10,4 @@ /* | ||
require('string.prototype.codepointat'); | ||
// Transform helpers (will move elsewhere later) | ||
@@ -416,3 +418,3 @@ function parseTransforms(value) { | ||
unicode="' + unicode.split('').map(function(char) { | ||
return '&#x' + char.charCodeAt(0).toString(16).toUpperCase() + ';'; | ||
return '&#x' + char.codePointAt(0).toString(16).toUpperCase() + ';'; | ||
}).join('') + '"\n\ | ||
@@ -419,0 +421,0 @@ horiz-adv-x="' + glyph.width + '" d="' + d +'" />\n'); |
var path = require('path'); | ||
var fs = require('fs'); | ||
require('string.fromcodepoint'); | ||
require('string.prototype.codepointat'); | ||
function getMetadataService(options) { | ||
@@ -31,3 +34,3 @@ var usedUnicodes = []; | ||
return match.split('u').map(function(code) { | ||
return String.fromCharCode(parseInt(code, 16)); | ||
return String.fromCodePoint(parseInt(code, 16)); | ||
}).join(''); | ||
@@ -42,3 +45,3 @@ }); | ||
do { | ||
metadata.unicode[0] = String.fromCharCode(options.startUnicode++); | ||
metadata.unicode[0] = String.fromCodePoint(options.startUnicode++); | ||
} while(-1 !== usedUnicodes.indexOf(metadata.unicode[0])); | ||
@@ -49,3 +52,3 @@ usedUnicodes.push(metadata.unicode[0]); | ||
metadata.path = path.dirname(file) + '/' + | ||
'u' + metadata.unicode[0].charCodeAt(0).toString(16).toUpperCase() + | ||
'u' + metadata.unicode[0].codePointAt(0).toString(16).toUpperCase() + | ||
'-' + basename; | ||
@@ -56,3 +59,3 @@ fs.rename(file, metadata.path, | ||
return cb(new Error('Could not save codepoint: ' + | ||
'u' + metadata.unicode[0].charCodeAt(0).toString(16).toUpperCase() + | ||
'u' + metadata.unicode[0].codePointAt(0).toString(16).toUpperCase() + | ||
' for ' + basename)); | ||
@@ -59,0 +62,0 @@ } |
@@ -5,2 +5,4 @@ var metadata = require(__dirname + '/../src/metadata.js'); | ||
require('string.fromcodepoint'); | ||
describe('Metadata service', function() { | ||
@@ -106,2 +108,17 @@ | ||
it("should work for higher codepoint codes", function(done) { | ||
var metadataService = metadata(); | ||
metadataService('/var/plop/u1F63A-hello.svg', function(err, infos) { | ||
assert(!err); | ||
assert.deepEqual(infos, { | ||
path: '/var/plop/u1F63A-hello.svg', | ||
name: 'hello', | ||
unicode: [String.fromCodePoint(0x1f63a)], | ||
renamed: false | ||
} | ||
); | ||
done(); | ||
}); | ||
}); | ||
it("should work for ligature codes", function(done) { | ||
@@ -140,4 +157,29 @@ var metadataService = metadata(); | ||
it("should not set the same codepoint twice", function(done) { | ||
var metadataService = metadata(); | ||
metadataService('/var/plop/uEA01-hello.svg', function(err, infos) { | ||
assert(!err); | ||
assert.deepEqual(infos, { | ||
path: '/var/plop/uEA01-hello.svg', | ||
name: 'hello', | ||
unicode: [String.fromCharCode(0xEA01)], | ||
renamed: false | ||
} | ||
); | ||
metadataService('/var/plop/plop.svg', function(err, infos) { | ||
assert(!err); | ||
assert.deepEqual(infos, { | ||
path: '/var/plop/plop.svg', | ||
name: 'plop', | ||
unicode: [String.fromCharCode(0xEA02)], | ||
renamed: false | ||
} | ||
); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
160823
104
1253
6
14
+ Addedstring.fromcodepoint@^0.2.1
+ Addedprocess-nextick-args@1.0.7(transitive)
+ Addedreadable-stream@2.0.6(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedstring.fromcodepoint@0.2.1(transitive)
+ Addedstring.prototype.codepointat@0.2.1(transitive)
+ Addedsvg-pathdata@1.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedsax@1.1.6(transitive)
- Removedsvg-pathdata@1.0.0(transitive)
Updatedreadable-stream@^2.0.1
Updatedsax@^1.1.1
Updatedsvg-pathdata@^1.0.1