From e17c9dc17aba099dff91a37f976cdba4eac24809 Mon Sep 17 00:00:00 2001 From: dpilafian Date: Fri, 10 Nov 2023 03:11:03 -0800 Subject: [PATCH] Release v1.1.1 --- dist/img-src-placeholder.d.ts | 9 ++++++--- dist/img-src-placeholder.js | 21 ++++++++++++++++++++- package.json | 14 +++++++------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/dist/img-src-placeholder.d.ts b/dist/img-src-placeholder.d.ts index f4ba2e7..ba77ade 100644 --- a/dist/img-src-placeholder.d.ts +++ b/dist/img-src-placeholder.d.ts @@ -1,4 +1,4 @@ -//! img-src-placeholder v1.1.0 ~~ https://github.com/center-key/img-src-placeholder ~~ MIT License +//! img-src-placeholder v1.1.1 ~~ https://github.com/center-key/img-src-placeholder ~~ MIT License import { Results } from 'replacer-util'; export type Settings = { @@ -6,9 +6,12 @@ export type Settings = { extensions: string[]; filename: string | null; }; -export type Options = Partial; +export type ReporterSettings = { + summaryOnly: boolean; +}; declare const imgSrcPlaceholder: { htmlExts: string[]; - transform(sourceFolder: string, targetFolder: string, options?: Options): Results; + transform(sourceFolder: string, targetFolder: string, options?: Partial): Results; + reporter(results: Results, options?: Partial): Results; }; export { imgSrcPlaceholder }; diff --git a/dist/img-src-placeholder.js b/dist/img-src-placeholder.js index eec67e8..34ac23f 100644 --- a/dist/img-src-placeholder.js +++ b/dist/img-src-placeholder.js @@ -1,6 +1,8 @@ -//! img-src-placeholder v1.1.0 ~~ https://github.com/center-key/img-src-placeholder ~~ MIT License +//! img-src-placeholder v1.1.1 ~~ https://github.com/center-key/img-src-placeholder ~~ MIT License import { replacer } from 'replacer-util'; +import chalk from 'chalk'; +import log from 'fancy-log'; const imgSrcPlaceholder = { htmlExts: ['.html', '.htm', '.php', '.aspx', '.asp', '.jsp'], transform(sourceFolder, targetFolder, options) { @@ -20,5 +22,22 @@ const imgSrcPlaceholder = { }; return replacer.transform(sourceFolder, targetFolder, replacerSettings); }, + reporter(results, options) { + const defaults = { + summaryOnly: false, + }; + const settings = { ...defaults, ...options }; + const name = chalk.gray('img-src-placeholder'); + const source = chalk.blue.bold(results.source); + const target = chalk.magenta(results.target); + const arrow = { big: chalk.gray.bold(' ⟹ '), little: chalk.gray.bold('→') }; + const infoColor = results.count ? chalk.white : chalk.red.bold; + const info = infoColor(`(files: ${results.count}, ${results.duration}ms)`); + log(name, source, arrow.big, target, info); + const logFile = (file) => log(name, chalk.white(file.origin), arrow.little, chalk.green(file.dest)); + if (!settings.summaryOnly) + results.files.forEach(logFile); + return results; + }, }; export { imgSrcPlaceholder }; diff --git a/package.json b/package.json index ba8a008..df173a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "img-src-placeholder", - "version": "1.1.0", + "version": "1.1.1", "description": "Replace src=# in tags of HTML files with an inline data URL of a transparent 1 pixel image (CLI tool designed for use in npm scripts)", "license": "MIT", "type": "module", @@ -87,24 +87,24 @@ "chalk": "~5.3", "cli-argv-util": "~1.2", "fancy-log": "~2.0", - "istextorbinary": "~6.0", + "istextorbinary": "~7.0", "replacer-util": "~1.2", "slash": "~5.1" }, "devDependencies": { "@types/fancy-log": "~2.0", - "@types/node": "~20.8", - "@typescript-eslint/eslint-plugin": "~6.7", - "@typescript-eslint/parser": "~6.7", + "@types/node": "~20.9", + "@typescript-eslint/eslint-plugin": "~6.10", + "@typescript-eslint/parser": "~6.10", "add-dist-header": "~1.3", "assert-deep-strict-equal": "~1.1", "copy-file-util": "~1.1", - "eslint": "~8.51", + "eslint": "~8.53", "jshint": "~2.13", "mocha": "~10.2", "rimraf": "~5.0", "run-scripts-util": "~1.2", "typescript": "~5.2", - "w3c-html-validator": "~1.5" + "w3c-html-validator": "~1.6" } }