Socket
Socket
Sign inDemoInstall

ecalper

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecalper

Command line search and replace utility.


Version published
Maintainers
1
Created
Source

ecalper

img-license img-github img-npm

ecalper is a command line utility for performing search-and-replace on files. It's similar to sed but there are a few differences:

  • Modifies files when matches are found
  • Recursive search on directories with -r
  • Uses JavaScript syntax for regular expressions and replacement strings.

Install

With node.js and npm:

npm i -g ecalper

You can now use ecalper and search from the command line.

Examples

Replace all occurrences of "foo" with "bar" in files in the current directory:

ecalper 'foo' 'bar' *

Replace in all files in a recursive search of the current directory:

ecalper 'foo' 'bar' . -r

Replace only in test/file1.js and test/file2.js:

ecalper 'foo' 'bar' test/file1.js test/file2.js

Replace all word pairs with "_" in middle with a "-":

ecalper '(\w+)_(\w+)' '$1-$2' *

Replace only in files with names matching *.js:

ecalper 'foo' 'bar' . -r --include="*.js"

Don't replace in files with names matching .min.js and.py:

ecalper 'foo' 'bar' . -r --exclude="*.min.js,*.py"

Preview the replacements without modifying any files:

ecalper 'foo' 'bar' . -r --preview

Replace using stdin:

echo "asd" | replace "asd" "dsa" -z

See all the options:

ecalper -h

There's also a search command. It's like grep, but with replace's syntax.

search "setTimeout" . -r

Programmatic Usage

You can use replace from your JS program:

import ecalper from 'ecalper'

ecalper({
  regex: "foo",
  replacement: "bar",
  paths: ['./Test/'],
  recursive: false,
  silent: false,
})

More Details

Excludes

By default, ecalper and search will exclude files (binaries, images, etc) that match patterns in the "defaultignore" located in this directory.

On huge directories

If ecalper is taking too long on a large directory, try turning on the quiet flag with -q, only including the necessary file types with --include or limiting the lines shown in a preview with -n.


Keywords

FAQs

Package last updated on 27 Feb 2022

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc