@warren-bank/edit-text-files
v1.0.0
Published
Apply a batch of search/replace operations on all text files in a directory tree.
Readme
edit-text-files
Apply a batch of search/replace operations on all text files in a directory tree.
Installation:
npm install --global @warren-bank/edit-text-filesUsage:
etf <options>
==================
options (general):
==================
"-h"
"--help"
Print a help message detailing all command-line options.
"-v"
"--version"
Display the version.
"-d" <dirpath>
"--dir" <dirpath>
Path to the root of a directory tree,
which contains the text files to edit.
"-e" <file-extension-csv>
"--file-extensions" <file-extension-csv>
File extension of text files to edit.
note: this option can be used multiple times.
note: multiple values can be entered in a comma-separated list.
default: "txt,xml"
"-c" <filepath>
"--config-file" <filepath>
Path to the configuration file,
which defines the search/replace operations.Configuration File:
- CommonJS module that exports an Array of Objects
- each Object:
- has 2 keys
s: search termr: replace term
- has 2 keys
- type of search term value can be:
- String
- case sensitive
- RegExp
- note: the global
gmodifier is added, if not explicitly set
- note: the global
- String
- type of replace term value can be:
- String
- replace all matching instances of the search term with this value
- empty value is OK
- boolean
false: remove all lines that contain any matching instance of the search term
- String
Configuration File Example:
configs.js
module.exports = [
{
s: 'foo',
r: 'bar'
},{
s: /(?:hello|hi|howdy)/ig,
r: 'goodbye'
},{
s: new RegExp('^\\s*(?:#|//|rem )'),
r: false
}
]Legal:
- copyright: Warren Bank
- license: GPL-2.0
