diff --git a/dist/replacer.d.ts b/dist/replacer.d.ts index 583ab9f..754819c 100644 --- a/dist/replacer.d.ts +++ b/dist/replacer.d.ts @@ -1,4 +1,4 @@ -//! replacer-util v1.2.2 ~~ https://github.com/center-key/replacer-util ~~ MIT License +//! replacer-util v1.2.3 ~~ https://github.com/center-key/replacer-util ~~ MIT License export type Settings = { cd: string | null; @@ -13,6 +13,7 @@ export type Settings = { regex: RegExp | null; rename: string | null; replacement: string | null; + templatingOn: boolean; }; export type Results = { source: string; diff --git a/dist/replacer.js b/dist/replacer.js index 5245c59..5f3b4b5 100644 --- a/dist/replacer.js +++ b/dist/replacer.js @@ -1,4 +1,4 @@ -//! replacer-util v1.2.2 ~~ https://github.com/center-key/replacer-util ~~ MIT License +//! replacer-util v1.2.3 ~~ https://github.com/center-key/replacer-util ~~ MIT License import { globSync } from 'glob'; import { isBinary } from 'istextorbinary'; @@ -43,6 +43,7 @@ const replacer = { noSourceMap: false, regex: null, replacement: null, + templatingOn: true, }; const settings = { ...defaults, ...options }; const startTime = Date.now(); @@ -104,7 +105,7 @@ const replacer = { const altText = settings.content ? render(settings.content) : null; const content = render(header) + (altText ?? fs.readFileSync(file.origin, 'utf-8')); const newStr = render(rep); - const out1 = render(content); + const out1 = settings.templatingOn ? render(content) : content; const out2 = out1.replace(normalizeEol, '').replace(normalizeEof, '\n'); const out3 = settings.find ? out2.replaceAll(settings.find, newStr) : out2; const out4 = settings.regex ? out3.replace(settings.regex, newStr) : out3; diff --git a/package.json b/package.json index e4c150b..c619a1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "replacer-util", - "version": "1.2.2", + "version": "1.2.3", "description": "Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)", "license": "MIT", "type": "module", diff --git a/spec/fixtures/target/bundle.js b/spec/fixtures/target/bundle.js index c3225a5..8076196 100644 --- a/spec/fixtures/target/bundle.js +++ b/spec/fixtures/target/bundle.js @@ -6,7 +6,7 @@ let π1 = 3.14; let τ1 = 2 * π1; const info1 = { - banner: '🔍🔍🔍 replacer-util v1.2.2 🔍🔍🔍', + banner: '🔍🔍🔍 replacer-util v1.2.3 🔍🔍🔍', 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', @@ -23,7 +23,7 @@ let π2 = 3.14; let τ2 = 2 * π2; const info2 = { - banner: '🔍🔍🔍 replacer-util v1.2.2 🔍🔍🔍', + banner: '🔍🔍🔍 replacer-util v1.2.3 🔍🔍🔍', description: 'Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)', code: 'mock2', file: '{"root":"","dir":"spec/fixtures/source/subfolder-a","base":"mock2.js","ext":".js","name":"mock2","path":"spec/fixtures/source/subfolder-a/mock2.js"}', diff --git a/spec/fixtures/target/mock1.html b/spec/fixtures/target/mock1.html index de1ebc3..d00c1d8 100644 --- a/spec/fixtures/target/mock1.html +++ b/spec/fixtures/target/mock1.html @@ -14,7 +14,7 @@

🔍🔍🔍 replacer-util 🔍🔍🔍

Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)

I, for one, welcome our new A.I. module overlords.

@@ -25,7 +25,7 @@

Find and replace strings or template outputs in text files (CLI tool designe let τ2 = 2 * π2; const info2 = { - banner: '🔍🔍🔍 replacer-util v1.2.2 🔍🔍🔍', + banner: '🔍🔍🔍 replacer-util v1.2.3 🔍🔍🔍', description: 'Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)', code: 'mock1', file: '{"root":"","dir":"spec/fixtures/source","base":"mock1.html","ext":".html","name":"mock1","path":"spec/fixtures/source/mock1.html"}', diff --git a/spec/fixtures/target/mock1.js b/spec/fixtures/target/mock1.js index f4ad57d..b46c4dd 100644 --- a/spec/fixtures/target/mock1.js +++ b/spec/fixtures/target/mock1.js @@ -5,7 +5,7 @@ let π1 = 3.14; let τ1 = 2 * π1; const info1 = { - banner: '🔍🔍🔍 replacer-util v1.2.2 🔍🔍🔍', + banner: '🔍🔍🔍 replacer-util v1.2.3 🔍🔍🔍', 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', diff --git a/spec/fixtures/target/subfolder-a/mock2.html b/spec/fixtures/target/subfolder-a/mock2.html index 74403ef..5139ec6 100644 --- a/spec/fixtures/target/subfolder-a/mock2.html +++ b/spec/fixtures/target/subfolder-a/mock2.html @@ -12,7 +12,7 @@

🔍🔍🔍 replacer-util 🔍🔍🔍

Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)

I, for one, welcome our new A.I. module overlords.

diff --git a/spec/fixtures/target/subfolder-a/mock2.js b/spec/fixtures/target/subfolder-a/mock2.js index 9715e84..a3f74f3 100644 --- a/spec/fixtures/target/subfolder-a/mock2.js +++ b/spec/fixtures/target/subfolder-a/mock2.js @@ -5,7 +5,7 @@ let π2 = 3.14; let τ2 = 2 * π2; const info2 = { - banner: '🔍🔍🔍 replacer-util v1.2.2 🔍🔍🔍', + banner: '🔍🔍🔍 replacer-util v1.2.3 🔍🔍🔍', description: 'Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)', code: 'mock2', file: '{"root":"","dir":"spec/fixtures/source/subfolder-a","base":"mock2.js","ext":".js","name":"mock2","path":"spec/fixtures/source/subfolder-a/mock2.js"}', diff --git a/spec/fixtures/target/web/index.html b/spec/fixtures/target/web/index.html index c4034dd..edd0a94 100644 --- a/spec/fixtures/target/web/index.html +++ b/spec/fixtures/target/web/index.html @@ -14,7 +14,7 @@

🔍🔍🔍 replacer-util 🔍🔍🔍

Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)

I, for one, welcome our new insect overlords.

@@ -25,7 +25,7 @@

Find and replace strings or template outputs in text files (CLI tool designe let τ2 = 2 * π2; const info2 = { - banner: '🔍🔍🔍 replacer-util v1.2.2 🔍🔍🔍', + banner: '🔍🔍🔍 replacer-util v1.2.3 🔍🔍🔍', description: 'Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)', code: 'mock1', file: '{"root":"","dir":"spec/fixtures/source","base":"mock1.html","ext":".html","name":"mock1","path":"spec/fixtures/source/mock1.html"}', diff --git a/spec/fixtures/target/web/subfolder-a/index.html b/spec/fixtures/target/web/subfolder-a/index.html index 3defa12..22a0b45 100644 --- a/spec/fixtures/target/web/subfolder-a/index.html +++ b/spec/fixtures/target/web/subfolder-a/index.html @@ -12,7 +12,7 @@

🔍🔍🔍 replacer-util 🔍🔍🔍

Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)

I, for one, welcome our new insect overlords.

diff --git a/spec/fixtures/target/web/subfolder-b/index.html b/spec/fixtures/target/web/subfolder-b/index.html index 3defa12..22a0b45 100644 --- a/spec/fixtures/target/web/subfolder-b/index.html +++ b/spec/fixtures/target/web/subfolder-b/index.html @@ -12,7 +12,7 @@

🔍🔍🔍 replacer-util 🔍🔍🔍

Find and replace strings or template outputs in text files (CLI tool designed for use in npm scripts)

I, for one, welcome our new insect overlords.