replace-in-files-cli
Advanced tools
Comparing version 2.2.0 to 3.0.0
export default function replaceInFiles( | ||
path: string | string[], | ||
options: { | ||
find: Array<string | RegExp>, | ||
replacement: string, | ||
ignoreCase?: boolean, | ||
glob?: boolean | ||
find: Array<string | RegExp>; | ||
replacement: string; | ||
ignoreCase?: boolean; | ||
glob?: boolean; | ||
}, | ||
): Promise<void>; |
@@ -31,7 +31,7 @@ import process from 'node:process'; | ||
replacement = replacement | ||
.replace(/\\n/g, '\n') | ||
.replace(/\\r/g, '\r') | ||
.replace(/\\t/g, '\t'); | ||
.replaceAll('\\n', '\n') | ||
.replaceAll('\\r', '\r') | ||
.replaceAll('\\t', '\t'); | ||
// TODO: Drop the `normalizePath` call when https://github.com/mrmlnc/fast-glob/issues/240 is fixed. | ||
// TODO: Drop the `normalizePath` call when `convertPathToPattern` from `fast-glob` is added to globby. | ||
filePaths = glob ? await globby(filePaths.map(filePath => normalizePath(filePath))) : [...new Set(filePaths.map(filePath => normalizePath(path.resolve(filePath))))]; | ||
@@ -38,0 +38,0 @@ |
20
cli.js
@@ -59,12 +59,10 @@ #!/usr/bin/env node | ||
(async () => { | ||
await replaceInFiles(cli.input, { | ||
find: [ | ||
...cli.flags.string, | ||
...cli.flags.regex.map(regexString => new RegExp(regexString, 'g')), | ||
], | ||
replacement: cli.flags.replacement, | ||
ignoreCase: cli.flags.ignoreCase, | ||
glob: cli.flags.glob, | ||
}); | ||
})(); | ||
await replaceInFiles(cli.input, { | ||
find: [ | ||
...cli.flags.string, | ||
...cli.flags.regex.map(regexString => new RegExp(regexString, 'g')), | ||
], | ||
replacement: cli.flags.replacement, | ||
ignoreCase: cli.flags.ignoreCase, | ||
glob: cli.flags.glob, | ||
}); |
{ | ||
"name": "replace-in-files-cli", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "Replace matching strings and regexes in files", | ||
@@ -21,8 +21,8 @@ "license": "MIT", | ||
}, | ||
"sideEffects": false, | ||
"engines": { | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"//test": "xo && ava", | ||
"test": "ava" | ||
"test": "xo && ava" | ||
}, | ||
@@ -54,13 +54,13 @@ "files": [ | ||
"escape-string-regexp": "^5.0.0", | ||
"globby": "^12.0.2", | ||
"meow": "^10.1.1", | ||
"globby": "^14.0.1", | ||
"meow": "^13.2.0", | ||
"normalize-path": "^3.0.0", | ||
"write-file-atomic": "^3.0.3" | ||
"write-file-atomic": "^5.0.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"execa": "^5.1.1", | ||
"ava": "^6.1.3", | ||
"execa": "^9.3.0", | ||
"temp-write": "^5.0.0", | ||
"xo": "^0.46.4" | ||
"xo": "^0.58.0" | ||
} | ||
} |
7312
117
+ Added@sindresorhus/merge-streams@2.3.0(transitive)
+ Addedglobby@14.0.2(transitive)
+ Addedmeow@13.2.0(transitive)
+ Addedpath-type@5.0.0(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedslash@5.1.0(transitive)
+ Addedunicorn-magic@0.1.0(transitive)
+ Addedwrite-file-atomic@5.0.1(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@types/minimist@1.2.5(transitive)
- Removed@types/normalize-package-data@2.4.4(transitive)
- Removedarray-union@3.0.1(transitive)
- Removedarrify@1.0.1(transitive)
- Removedcamelcase@6.3.0(transitive)
- Removedcamelcase-keys@7.0.2(transitive)
- Removeddecamelize@1.2.05.0.1(transitive)
- Removeddecamelize-keys@1.1.1(transitive)
- Removeddir-glob@3.0.1(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@5.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedglobby@12.2.0(transitive)
- Removedhard-rejection@2.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@4.1.0(transitive)
- Removedindent-string@5.0.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.16.1(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjson-parse-even-better-errors@2.3.1(transitive)
- Removedkind-of@6.0.3(transitive)
- Removedlines-and-columns@1.2.4(transitive)
- Removedlocate-path@6.0.0(transitive)
- Removedlru-cache@6.0.0(transitive)
- Removedmap-obj@1.0.14.3.0(transitive)
- Removedmeow@10.1.5(transitive)
- Removedmin-indent@1.0.1(transitive)
- Removedminimist-options@4.1.0(transitive)
- Removednormalize-package-data@3.0.3(transitive)
- Removedp-limit@3.1.0(transitive)
- Removedp-locate@5.0.0(transitive)
- Removedparse-json@5.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedquick-lru@5.1.1(transitive)
- Removedread-pkg@6.0.0(transitive)
- Removedread-pkg-up@8.0.0(transitive)
- Removedredent@4.0.0(transitive)
- Removedsemver@7.6.3(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedslash@4.0.0(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.21(transitive)
- Removedstrip-indent@4.0.0(transitive)
- Removedtrim-newlines@4.1.1(transitive)
- Removedtype-fest@1.4.0(transitive)
- Removedtypedarray-to-buffer@3.1.5(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedwrite-file-atomic@3.0.3(transitive)
- Removedyallist@4.0.0(transitive)
- Removedyargs-parser@20.2.9(transitive)
- Removedyocto-queue@0.1.0(transitive)
Updatedglobby@^14.0.1
Updatedmeow@^13.2.0
Updatedwrite-file-atomic@^5.0.1