Socket
Book a DemoInstallSign in
Socket

file-line-replacer

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-line-replacer

Replaces multiple lines within large text files.

latest
Source
npmnpm
Version
0.6.0
Version published
Weekly downloads
20
185.71%
Maintainers
1
Weekly downloads
 
Created
Source

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)`stringstring[]`
ignore-patterns-delimiterIgnore Patterns Delimeter(function)
ignore-patterns-fileIgnore Patterns Filestring (path)
make-dirsMake Directories Flagbooleantrue
match-whitespaceMatch Whitespace Flagbooleanfalse
new-linesNew Line(s)`stringstring[]`
new-lines-delimiterNew Lines Delimeter(function)
new-lines-fileNew Lines Filestring (path)
old-linesOld Line(s)`stringstring[]`
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

Keywords

sed

FAQs

Package last updated on 29 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.