Skip to content

Commit

Permalink
Release v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Sep 25, 2023
1 parent ea1ae2a commit 7643c17
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 16 deletions.
9 changes: 6 additions & 3 deletions dist/replacer.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! replacer-util v1.2.0 ~~ https://github.com/center-key/replacer-util ~~ MIT License
//! replacer-util v1.2.1 ~~ https://github.com/center-key/replacer-util ~~ MIT License

export type Settings = {
cd: string | null;
Expand All @@ -15,7 +15,6 @@ export type Settings = {
rename: string | null;
replacement: string | null;
};
export type Options = Partial<Settings>;
export type Results = {
source: string;
target: string;
Expand All @@ -27,7 +26,11 @@ export type Results = {
}[];
};
export type ResultsFile = Results['files'][0];
export type ReporterSettings = {
summaryOnly: boolean;
};
declare const replacer: {
transform(sourceFolder: string, targetFolder: string, options?: Options): Results;
transform(sourceFolder: string, targetFolder: string, options?: Partial<Settings>): Results;
reporter(results: Results, options?: Partial<ReporterSettings>): Results;
};
export { replacer };
21 changes: 20 additions & 1 deletion dist/replacer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! replacer-util v1.2.0 ~~ https://github.com/center-key/replacer-util ~~ MIT License
//! replacer-util v1.2.1 ~~ https://github.com/center-key/replacer-util ~~ MIT License

import { globSync } from 'glob';
import { isBinary } from 'istextorbinary';
import { Liquid } from 'liquidjs';
import chalk from 'chalk';
import fs from 'fs';
import log from 'fancy-log';
import path from 'path';
import slash from 'slash';
const task = {
Expand Down Expand Up @@ -121,5 +123,22 @@ const replacer = {
files: fileRoutes.map(relativePaths),
};
},
reporter(results, options) {
const defaults = {
summaryOnly: false,
};
const settings = { ...defaults, ...options };
const name = chalk.gray('replacer');
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 { replacer };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "replacer-util",
"version": "1.2.0",
"version": "1.2.1",
"description": "Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)",
"license": "MIT",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/target/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions spec/fixtures/target/mock1.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>🔍🔍🔍 replacer-util 🔍🔍🔍</h1>
<h2>Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)</h2>
<p>I, for one, welcome our new A.I. module overlords.</p>
<ul>
<li>Release: v1.2.0</li>
<li>Release: v1.2.1</li>
<li>Minor: v1.2</li>
<li>Major: v1</li>
</ul>
Expand All @@ -25,7 +25,7 @@ <h2>Find and replace strings or template outputs in text files (CLI tool designe
let τ2 = 2 * π2;

const info2 = {
banner: '🔍🔍🔍 replacer-util v1.2.0 🔍🔍🔍',
banner: '🔍🔍🔍 replacer-util v1.2.1 🔍🔍🔍',
description: 'Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)',
list1: 'A.I. module, A.I. module, A.I. module',
list2: 'A.I. module, iNsEcT, INSECT, A.I. module',
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/target/mock1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let π1 = 3.14;
let τ1 = 2 * π1;

const info1 = {
banner: '🔍🔍🔍 replacer-util v1.2.0 🔍🔍🔍',
banner: '🔍🔍🔍 replacer-util v1.2.1 🔍🔍🔍',
description: 'Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)',
list1: 'A.I. module, A.I. module, A.I. module',
list2: 'A.I. module, iNsEcT, INSECT, A.I. module',
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/target/subfolder-a/mock2.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>🔍🔍🔍 replacer-util 🔍🔍🔍</h1>
<h2>Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)</h2>
<p>I, for one, welcome our new A.I. module overlords.</p>
<ul>
<li>Release: v1.2.0</li>
<li>Release: v1.2.1</li>
<li>Minor: v1.2</li>
<li>Major: v1</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/target/subfolder-a/mock2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let π2 = 3.14;
let τ2 = 2 * π2;

const info2 = {
banner: '🔍🔍🔍 replacer-util v1.2.0 🔍🔍🔍',
banner: '🔍🔍🔍 replacer-util v1.2.1 🔍🔍🔍',
description: 'Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)',
list1: 'A.I. module, A.I. module, A.I. module',
list2: 'A.I. module, iNsEcT, INSECT, A.I. module',
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/target/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>🔍🔍🔍 replacer-util 🔍🔍🔍</h1>
<h2>Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)</h2>
<p>I, for one, welcome our new insect overlords.</p>
<ul>
<li>Release: v1.2.0</li>
<li>Release: v1.2.1</li>
<li>Minor: v1.2</li>
<li>Major: v1</li>
</ul>
Expand All @@ -25,7 +25,7 @@ <h2>Find and replace strings or template outputs in text files (CLI tool designe
let τ2 = 2 * π2;

const info2 = {
banner: '🔍🔍🔍 replacer-util v1.2.0 🔍🔍🔍',
banner: '🔍🔍🔍 replacer-util v1.2.1 🔍🔍🔍',
description: 'Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)',
list1: 'insect, insect, insect',
list2: 'insect, iNsEcT, INSECT, insect',
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/target/web/subfolder-a/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>🔍🔍🔍 replacer-util 🔍🔍🔍</h1>
<h2>Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)</h2>
<p>I, for one, welcome our new insect overlords.</p>
<ul>
<li>Release: v1.2.0</li>
<li>Release: v1.2.1</li>
<li>Minor: v1.2</li>
<li>Major: v1</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/target/web/subfolder-b/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>🔍🔍🔍 replacer-util 🔍🔍🔍</h1>
<h2>Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)</h2>
<p>I, for one, welcome our new insect overlords.</p>
<ul>
<li>Release: v1.2.0</li>
<li>Release: v1.2.1</li>
<li>Minor: v1.2</li>
<li>Major: v1</li>
</ul>
Expand Down

0 comments on commit 7643c17

Please sign in to comment.