Skip to content

Replace a regex in one file with the contents of another.

License

Notifications You must be signed in to change notification settings

VinSpee/rereplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis Test Coverage Code Climate

rereplace

rereplace simply takes a regex with a capture group, reads a file, and replaces the capture group with the contents of another file.

Origin

I switched an entire build over to using cli tools and npm scripts. I ran into a problem with an svg spritesheet generating library – I needed to inject the output into a template. I slammed my head against the wall with sed and awk for a while, but finally decided to write a simple module that will do exactly what I ask using JS-compatible regexes.

Installation

npm i -S rereplace

Use

CLI

rereplace '/your-regex-as-a-string/' infile.html outfile.txt

as a module

import rereplace from 'rereplace';

rereplace('/your-regex-as-a-string/', './path/to/infile.html',
'./path/to/outfile.txt');

About

Replace a regex in one file with the contents of another.

Resources

License

Stars

Watchers

Forks

Packages

No packages published