0.6.0 • Published 4 years ago

file-line-replacer v0.6.0

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
4 years ago

File Line Replacer for NodeJS

The following document applies to the command-line usage of file-line-replacer. For usage directly in a Node application, please see the alternate README located here.

Purpose

Matches multiple lines within large text files and replaces those lines with another set of lines while optionally preserving whitespace. Both the old and new sets of lines may be passed in or read from a file. Of course, the original file may be automatically backed up, if desired.

Installation

npm i -g file-line-replacer

Usage

Tweak a single file ...

file-line-replacer \
  --source-file "/Volumes/Source/my-project/models/cat.model.js" \
  --old-lines "allowNull: false,|primaryKey: true"
  --new-lines "autoIncrement: true,|primaryKey: true" \
  --overwrite

... or, search entire directories for eligible files ...

file-line-replacer \
  --search-dir "/Users/flackey/my-project/src/data/models" \
  --backup-dir "/Users/flackey/my-project/_backup" \
  --old-lines "allowNull: false,|primaryKey: true" \
  --new-lines "autoIncrement: true,|primaryKey: true" \
  --overwrite

Parameters

NameDescriptionTypeDefault
backup-dirBackup Directorystring (path)
backup-dir-dateAppend Date Flag for Backup Directorybooleantrue
case-sensitiveCase Sensitive Flagbooleanfalse
delimiterDelimeter Character(s)|
destination-dirDestination Directorystring (path)(function)
destination-fileDestination Filestring (path)(function)
empty-linesPreserve Empty Lines Flagbooleanfalse
empty-lines-newPreserve Empty for New Files Lines Flagboolean(function)
empty-lines-oldPreserve Empty for Old Files Lines Flagboolean(function)
ignore-patternsIgnore Pattern(s)string | string[]
ignore-patterns-delimiterIgnore Patterns Delimeter(function)
ignore-patterns-fileIgnore Patterns Filestring (path)
make-dirsMake Directories Flagbooleantrue
match-whitespaceMatch Whitespace Flagbooleanfalse
new-linesNew Line(s)string | string[]
new-lines-delimiterNew Lines Delimeter(function)
new-lines-fileNew Lines Filestring (path)
old-linesOld Line(s)string | string[]
old-lines-delimiterOld Lines Delimeter(function)
old-lines-fileOld Lines Filestring (path)
overwriteOverwrite Files Flagbooleanfalse
preserve-whitespacePreserve Whitespace Flagbooleantrue
search-dirSearch Directorystring (path)
search-patternsSearch Pattern(s)
search-patterns-fileSearch Patterns Filestring (path)
source-fileSource Filestring (path)
temp-dirCustom Temp Directorystring (path)(function)

Contact

Please feel free to contact me directly with any questions, comments, or enhancement requests:

Fred Lackey
fred.lackey@gmail.com
http://fredlackey.com

0.6.0

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.5.2

4 years ago

0.4.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago