From ec1a9fd3c837b92edf42dcd0c84837ca7fde9afb Mon Sep 17 00:00:00 2001 From: dpilafian Date: Mon, 6 Nov 2023 03:03:43 -0800 Subject: [PATCH] Release v1.1.2 --- dist/copy-folder.d.ts | 9 ++++++--- dist/copy-folder.js | 21 ++++++++++++++++++++- package.json | 8 ++++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/dist/copy-folder.d.ts b/dist/copy-folder.d.ts index b77b01d..86b9e07 100644 --- a/dist/copy-folder.d.ts +++ b/dist/copy-folder.d.ts @@ -1,11 +1,10 @@ -//! copy-folder-util v1.1.1 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License +//! copy-folder-util v1.1.2 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License export type Settings = { basename: string; cd: string; fileExtensions: string[]; }; -export type Options = Partial; export type Results = { source: string; target: string; @@ -16,7 +15,11 @@ export type Results = { dest: string; }[]; }; +export type ReporterSettings = { + summaryOnly: boolean; +}; declare const copyFolder: { - cp(sourceFolder: string, targetFolder: string, options?: Options): Results; + cp(sourceFolder: string, targetFolder: string, options?: Partial): Results; + reporter(results: Results, options?: Partial): Results; }; export { copyFolder }; diff --git a/dist/copy-folder.js b/dist/copy-folder.js index 5524a90..6b9bbcb 100644 --- a/dist/copy-folder.js +++ b/dist/copy-folder.js @@ -1,6 +1,8 @@ -//! copy-folder-util v1.1.1 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License +//! copy-folder-util v1.1.2 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License +import chalk from 'chalk'; import fs from 'fs'; +import log from 'fancy-log'; import path from 'path'; import slash from 'slash'; const extraneousFiles = ['.DS_Store', 'Thumbs.db', 'desktop.ini']; @@ -61,5 +63,22 @@ const copyFolder = { files: files, }; }, + reporter(results, options) { + const defaults = { + summaryOnly: false, + }; + const settings = { ...defaults, ...options }; + const name = chalk.gray('copy-folder'); + 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 { copyFolder }; diff --git a/package.json b/package.json index df18db1..7c21b55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "copy-folder-util", - "version": "1.1.1", + "version": "1.1.2", "description": "Recursively copy files from one folder to another folder (CLI tool designed for use in npm scripts)", "license": "MIT", "type": "module", @@ -94,12 +94,12 @@ "devDependencies": { "@types/fancy-log": "~2.0", "@types/node": "~20.8", - "@typescript-eslint/eslint-plugin": "~6.7", - "@typescript-eslint/parser": "~6.7", + "@typescript-eslint/eslint-plugin": "~6.9", + "@typescript-eslint/parser": "~6.9", "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",