Socket
Socket
Sign inDemoInstall

icon-gen

Package Overview
Dependencies
54
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 4.0.0

2

dist/bin/cli.d.ts
import { ICONOptions } from '../lib/index';
/** Options of command line interface. */
declare type CLIOptions = {
type CLIOptions = {
/** Path of the SVG file or PNG file directory. */

@@ -5,0 +5,0 @@ input: string;

import { ImageInfo } from './png';
import Logger from './logger';
/** Options ot generate ICO file. */
export declare type FavOptions = {
export type FavOptions = {
/** Prefix of an output PNG files. Start with the alphabet, can use `-` and `_`. This option is for PNG. The name of the ICO file is always `favicon.ico`. */

@@ -6,0 +6,0 @@ name?: string;

import { ImageInfo } from './png';
import Logger from './logger';
/** Options of ICNS. */
export declare type ICNSOptions = {
export type ICNSOptions = {
/** Name of an output file. */

@@ -6,0 +6,0 @@ name?: string;

import { ImageInfo } from './png';
import Logger from './logger';
/** Options of `generateICO`. */
export declare type ICOOptions = {
export type ICOOptions = {
/** Name of an output file. */

@@ -6,0 +6,0 @@ name?: string;

/** Options of icon generation. */
export declare type ICONOptions = {
export type ICONOptions = {
/** Output setting of ICO file. */

@@ -4,0 +4,0 @@ ico?: {

@@ -29,8 +29,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const del_1 = __importDefault(require("del"));
const os_1 = __importDefault(require("os"));
const uuid_1 = require("uuid");
const mkdirp_1 = __importDefault(require("mkdirp"));
const node_fs_1 = __importDefault(require("node:fs"));
const node_path_1 = __importDefault(require("node:path"));
const png_1 = __importDefault(require("./png"));

@@ -103,4 +99,4 @@ const ico_1 = __importStar(require("./ico"));

}
const dir = path_1.default.resolve(dest);
mkdirp_1.default.sync(dir);
const dir = node_path_1.default.resolve(dest);
node_fs_1.default.mkdirSync(dir, { recursive: true });
const results = [];

@@ -130,4 +126,4 @@ if (options.icns) {

const generateIconFromPNG = (src, dir, options, logger) => {
const pngDirPath = path_1.default.resolve(src);
const destDirPath = path_1.default.resolve(dir);
const pngDirPath = node_path_1.default.resolve(src);
const destDirPath = node_path_1.default.resolve(dir);
logger.log('Icon generator from PNG:');

@@ -138,6 +134,6 @@ logger.log(' src: ' + pngDirPath);

.map((size) => {
return path_1.default.join(pngDirPath, size + '.png');
return node_path_1.default.join(pngDirPath, size + '.png');
})
.map((filePath) => {
const size = Number(path_1.default.basename(filePath, '.png'));
const size = Number(node_path_1.default.basename(filePath, '.png'));
return { filePath, size };

@@ -147,5 +143,5 @@ });

images.some((image) => {
const stat = fs_1.default.statSync(image.filePath);
const stat = node_fs_1.default.statSync(image.filePath);
if (!(stat && stat.isFile())) {
notExistsFile = path_1.default.basename(image.filePath);
notExistsFile = node_path_1.default.basename(image.filePath);
return true;

@@ -169,21 +165,15 @@ }

const generateIconFromSVG = async (src, dir, options, logger) => {
const svgFilePath = path_1.default.resolve(src);
const destDirPath = path_1.default.resolve(dir);
const svgFilePath = node_path_1.default.resolve(src);
const destDirPath = node_path_1.default.resolve(dir);
logger.log('Icon generator from SVG:');
logger.log(' src: ' + svgFilePath);
logger.log(' dir: ' + destDirPath);
const workDir = path_1.default.join(os_1.default.tmpdir(), (0, uuid_1.v4)());
fs_1.default.mkdirSync(workDir);
if (!fs_1.default.existsSync(workDir)) {
throw new Error('Failed to create the working directory.');
}
const workDir = node_fs_1.default.mkdtempSync('icon-gen-');
try {
const images = await (0, png_1.default)(svgFilePath, workDir, getRequiredPNGImageSizes(options), logger);
const results = await generate(images, destDirPath, options, logger);
del_1.default.sync([workDir], { force: true });
return results;
}
catch (err) {
del_1.default.sync([workDir], { force: true });
throw err;
finally {
node_fs_1.default.rmSync(workDir, { force: true, recursive: true });
}

@@ -199,6 +189,6 @@ };

const generateIcon = async (src, dest, options = { ico: {}, icns: {}, favicon: {}, report: false }) => {
if (!fs_1.default.existsSync(src)) {
if (!node_fs_1.default.existsSync(src)) {
throw new Error('Input file or directory is not found.');
}
if (!fs_1.default.existsSync(dest)) {
if (!node_fs_1.default.existsSync(dest)) {
throw new Error('Output directory is not found.');

@@ -213,3 +203,3 @@ }

const logger = new logger_1.default(options.report);
if (fs_1.default.statSync(src).isDirectory()) {
if (node_fs_1.default.statSync(src).isDirectory()) {
return generateIconFromPNG(src, dest, options, logger);

@@ -216,0 +206,0 @@ }

import Logger from './logger';
/** Image file information. */
export declare type ImageInfo = {
export type ImageInfo = {
/** Image size (width/height). */

@@ -5,0 +5,0 @@ size: number;

{
"name": "icon-gen",
"description": "Generate an icon files from the SVG or PNG files",
"version": "3.0.1",
"version": "4.0.0",
"author": "akabeko (http://akabeko.me/)",

@@ -9,4 +9,7 @@ "license": "MIT",

"engines": {
"node": ">= 12"
"node": ">= 18"
},
"volta": {
"node": "18.17.0"
},
"main": "dist/lib/index.js",

@@ -33,3 +36,3 @@ "bin": {

"scripts": {
"test": "jest",
"test": "vitest",
"start": "npm run watch",

@@ -43,20 +46,12 @@ "tsc": "tsc --noEmit",

"commander": "^8.3.0",
"del": "^6.0.0",
"mkdirp": "^1.0.4",
"pngjs": "^6.0.0",
"sharp": "^0.30.4",
"uuid": "^8.3.2"
"pngjs": "^7.0.0",
"sharp": "^0.32.4"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^27.5.0",
"@types/mkdirp": "^1.0.2",
"@types/node": "^17.0.31",
"@types/node": "^20.4.5",
"@types/pngjs": "^6.0.1",
"@types/sharp": "^0.30.2",
"@types/uuid": "^8.3.4",
"jest": "^27.4.3",
"ts-jest": "^27.1.4",
"typescript": "^4.6.4"
"@types/sharp": "^0.32.0",
"typescript": "^5.1.6",
"vitest": "^0.33.0"
}
}

@@ -47,3 +47,3 @@ # npm-icon-gen

The quality of PNG generated from SVG will change, so if you need the previous results, use icon-gen v2.1.0.
The quality of PNG generated from SVG will change, so if you need the previous results, use `icon-gen v2.1.0` (old version).

@@ -50,0 +50,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc