svgfont2svgicons
Advanced tools
Comparing version 2.0.0 to 3.0.0
#! /usr/bin/env node | ||
var svgfont2svgicons = require(__dirname + '/../src/index.js') | ||
, Fs = require('fs') | ||
, path = require('path') | ||
; | ||
import { SVGFont2SVGIconsStream } from '../dist/index.js'; | ||
import { createReadStream, createWriteStream } from 'node:fs'; | ||
import { readFile } from 'node:fs/promises'; | ||
import { join } from 'node:path'; | ||
import { argv, exit } from 'node:process'; | ||
import program from 'commander'; | ||
var fontStream = Fs.createReadStream(process.argv[2]); | ||
var iconProvider = svgfont2svgicons(); | ||
var unamedIconCount = 0; | ||
program | ||
.version('2.0.0') | ||
.usage('[options] <font file> <destination path>') | ||
.option('--namemap <json file>', 'get unicode to name map from json file', '') | ||
.parse(argv); | ||
if (program.args.length < 2) { | ||
console.log('Usage: node svgfont2svgicons', program.usage()); | ||
exit(1); | ||
} | ||
const srcFile = program.args[0], | ||
destPath = program.args[1], | ||
options = {}; | ||
if (program.namemap) | ||
options.nameMap = JSON.parse(await readFile(program.namemap)); | ||
const fontStream = createReadStream(srcFile); | ||
const iconProvider = new SVGFont2SVGIconsStream(options); | ||
fontStream.pipe(iconProvider); | ||
iconProvider.on('readable', function() { | ||
var glyph, steam, glyphPath; | ||
while(null !== glyph) { | ||
glyph = iconProvider.read(); | ||
if(glyph) { | ||
glyphPath = path.join(process.argv[3], glyph.name + '.svg'); | ||
console.log('Saving glyph "' + glyph.name + '" to "' + glyphPath + '"'); | ||
glyph.stream.pipe(Fs.createWriteStream(glyphPath)); | ||
} | ||
iconProvider.on('readable', function () { | ||
let glyph; | ||
while ((glyph = iconProvider.read()) !== null) { | ||
const glyphName = glyph.metadata.name; | ||
const glyphPath = join(destPath, glyphName + '.svg'); | ||
console.log('Saving glyph "' + glyphName + '" to "' + glyphPath + '"'); | ||
glyph.pipe(createWriteStream(glyphPath)); | ||
} | ||
}); | ||
162
package.json
{ | ||
"metapak": { | ||
"data": { | ||
"files": "src/*.ts", | ||
"testFiles": "tests/*.test.ts", | ||
"bundleFiles": [ | ||
"dist", | ||
"src", | ||
"bin" | ||
], | ||
"ignore": [ | ||
"dist" | ||
] | ||
}, | ||
"configs": [ | ||
"main", | ||
"readme", | ||
"jest", | ||
"eslint", | ||
"tsesm", | ||
"codeclimate", | ||
"ghactions" | ||
] | ||
}, | ||
"name": "svgfont2svgicons", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Extract SVG icons from an SVG font", | ||
"homepage": "https://github.com/nfroidure/svgfont2svgicons", | ||
"main": "src/index.js", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"test": "node_modules/mocha/bin/mocha tests/*.mocha.js", | ||
"coveralls": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", | ||
"cover": "./node_modules/istanbul/lib/cli.js cover --report html ./node_modules/mocha/bin/_mocha -- tests/*.mocha.js -R spec -t 5000" | ||
"build": "rimraf 'dist' && tsc --outDir dist", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md", | ||
"cli": "env NODE_ENV=${NODE_ENV:-cli}", | ||
"cover": "npm run jest -- --coverage", | ||
"cz": "env NODE_ENV=${NODE_ENV:-cli} git cz", | ||
"format": "npm run prettier", | ||
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest", | ||
"lint": "eslint src/*.ts", | ||
"metapak": "metapak", | ||
"precz": "npm t && npm run lint && npm run metapak -- -s && npm run build", | ||
"prettier": "prettier --write src/*.ts", | ||
"preversion": "npm t && npm run lint && npm run metapak -- -s && npm run build", | ||
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022", | ||
"test": "npm run jest", | ||
"type-check": "tsc --pretty --noEmit", | ||
"version": "npm run changelog" | ||
}, | ||
@@ -24,19 +60,34 @@ "repository": { | ||
"dependencies": { | ||
"sax": "1.1.x", | ||
"svg-pathdata": "1.0.0", | ||
"readable-stream": "^2.0.0", | ||
"plexer": "0.0.3", | ||
"streamqueue": "^1.1.0" | ||
"commander": "^12.1.0", | ||
"sax": "^1.4.1", | ||
"streamqueue": "^2.0.0", | ||
"svg-pathdata": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "~2.11.2", | ||
"istanbul": "~0.3.15", | ||
"mocha": "~2.2.5", | ||
"mocha-lcov-reporter": "0.0.2", | ||
"streamtest": "^1.2.0", | ||
"svgicons2svgfont": "^2.0.2" | ||
"@eslint/js": "^9.7.0", | ||
"@swc/cli": "^0.4.0", | ||
"@swc/core": "^1.6.13", | ||
"@swc/helpers": "^0.5.12", | ||
"@swc/jest": "^0.2.36", | ||
"commitizen": "^4.3.0", | ||
"conventional-changelog-cli": "^5.0.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^9.7.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-jest": "^28.6.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"jest": "^29.7.0", | ||
"metapak": "^6.0.1", | ||
"metapak-nfroidure": "18.2.0", | ||
"prettier": "^3.3.3", | ||
"rimraf": "^6.0.1", | ||
"streamtest": "^3.0.1", | ||
"svgicons2svgfont": "^14.0.1", | ||
"typescript": "^5.5.3", | ||
"typescript-eslint": "^7.16.0" | ||
}, | ||
"author": { | ||
"name": "Nicolas Froidure", | ||
"url": "http://www.insertafter.com/blog.html" | ||
"email": "nicolas.froidure@insertafter.com", | ||
"url": "https://insertafter.com/en/index.html" | ||
}, | ||
@@ -52,6 +103,79 @@ "licenses": [ | ||
}, | ||
"preferGlobal": "true", | ||
"bin": { | ||
"svgfont2svgicons": "bin/svgfont2svgicons.js" | ||
} | ||
}, | ||
"contributors": [], | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=20.11.1" | ||
}, | ||
"files": [ | ||
"dist", | ||
"src", | ||
"bin", | ||
"LICENSE", | ||
"README.md", | ||
"CHANGELOG.md" | ||
], | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
}, | ||
"greenkeeper": { | ||
"ignore": [ | ||
"commitizen", | ||
"cz-conventional-changelog", | ||
"conventional-changelog-cli", | ||
"jest", | ||
"@swc/jest", | ||
"eslint", | ||
"prettier", | ||
"eslint-config-prettier", | ||
"eslint-plugin-prettier", | ||
"typescript-eslint", | ||
"typescript", | ||
"rimraf", | ||
"@swc/cli", | ||
"@swc/core", | ||
"@swc/helpers" | ||
] | ||
}, | ||
"jest": { | ||
"coverageReporters": [ | ||
"lcov" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/" | ||
], | ||
"roots": [ | ||
"<rootDir>/src" | ||
], | ||
"transform": { | ||
"^.+\\.tsx?$": [ | ||
"@swc/jest", | ||
{} | ||
] | ||
}, | ||
"testEnvironment": "node", | ||
"moduleNameMapper": { | ||
"(.+)\\.js": "$1" | ||
}, | ||
"extensionsToTreatAsEsm": [ | ||
".ts" | ||
], | ||
"prettierPath": null | ||
}, | ||
"overrides": { | ||
"eslint": "^9.7.0" | ||
}, | ||
"prettier": { | ||
"semi": true, | ||
"printWidth": 80, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"proseWrap": "always" | ||
}, | ||
"type": "module", | ||
"types": "dist/index.d.ts" | ||
} |
@@ -0,15 +1,26 @@ | ||
[//]: # ( ) | ||
[//]: # (This file is automatically generated by a `metapak`) | ||
[//]: # (module. Do not change it except between the) | ||
[//]: # (`content:start/end` flags, your changes would) | ||
[//]: # (be overridden.) | ||
[//]: # ( ) | ||
# svgfont2svgicons | ||
> svgfont2svgicons is a simple tool to explode a SVG font into multiple icons. | ||
> Extract SVG icons from an SVG font | ||
[![NPM version](https://badge.fury.io/js/svgfont2svgicons.png)](https://npmjs.org/package/svgfont2svgicons) [![Build status](https://secure.travis-ci.org/nfroidure/svgfont2svgicons.png)](https://travis-ci.org/nfroidure/svgfont2svgicons) [![Dependency Status](https://david-dm.org/nfroidure/svgfont2svgicons.png)](https://david-dm.org/nfroidure/svgfont2svgicons) [![devDependency Status](https://david-dm.org/nfroidure/svgfont2svgicons/dev-status.png)](https://david-dm.org/nfroidure/svgfont2svgicons#info=devDependencies) [![Coverage Status](https://coveralls.io/repos/nfroidure/svgfont2svgicons/badge.png?branch=master)](https://coveralls.io/r/nfroidure/svgfont2svgicons?branch=master) [![Code Climate](https://codeclimate.com/github/nfroidure/svgfont2svgicons.png)](https://codeclimate.com/github/nfroidure/svgfont2svgicons) | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/svgfont2svgicons/blob/main/LICENSE) | ||
## Usage | ||
[//]: # (::contents:start) | ||
## Usage | ||
### In your scripts | ||
```js | ||
var svgfont2svgicons = require('svgfont2svgicons'); | ||
var fs = require('fs'); | ||
var fontStream = fs.createReadStream('myFont.svg'); | ||
var iconProvider = svgfont2svgicons(options); | ||
import svgfont2svgicons from 'svgfont2svgicons'; | ||
import fs from 'node:fs'; | ||
const fontStream = fs.createReadStream('myFont.svg'); | ||
const iconProvider = svgfont2svgicons(options); | ||
// Piping the font | ||
@@ -20,4 +31,5 @@ fontStream.pipe(iconProvider); | ||
iconProvider.on('readable', function() { | ||
var icon; | ||
do { | ||
let icon; | ||
do { | ||
icon = iconProvider.read(); | ||
@@ -30,7 +42,7 @@ if(icon) { | ||
}).once('end', function() { | ||
console.log('No more icons !') | ||
console.log('No more icons!') | ||
}); | ||
``` | ||
## CLI interface | ||
## CLI interface | ||
```sh | ||
@@ -45,9 +57,13 @@ svgfont2svgicons font/src/file.svg icons/dest/directory | ||
## Stats | ||
[![NPM](https://nodei.co/npm/svgfont2svgicons.png?downloads=true&stars=true)](https://nodei.co/npm/svgicon2svgfont/) | ||
[![NPM](https://nodei.co/npm-dl/svgfont2svgicons.png)](https://nodei.co/npm/svgicon2svgfont/) | ||
## Contributing | ||
Feel free to pull your code if you agree with publishing under the MIT license. | ||
[//]: # (::contents:end) | ||
# Authors | ||
- [Nicolas Froidure](https://insertafter.com/en/index.html) | ||
# License | ||
[MIT](https://github.com/nfroidure/svgfont2svgicons/blob/main/LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
30421
4
438
67
0
Yes
21
13
1
+ Addedcommander@^12.1.0
+ Addedcommander@12.1.0(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedstreamqueue@2.0.0(transitive)
+ Addedsvg-pathdata@7.1.0(transitive)
+ Addedyerror@8.0.0(transitive)
- Removedplexer@0.0.3
- Removedreadable-stream@^2.0.0
- Removedcore-util-is@1.0.3(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.11.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedplexer@0.0.3(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@1.0.341.1.142.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsax@1.1.6(transitive)
- Removedstreamqueue@1.1.2(transitive)
- Removedstring_decoder@0.10.311.1.1(transitive)
- Removedsvg-pathdata@1.0.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedsax@^1.4.1
Updatedstreamqueue@^2.0.0
Updatedsvg-pathdata@^7.0.0