replace-require-regex

1.1.0 • Public • Published

replace-require-regex

NPM version Build Status

regex based require/import replacements for js files

Install

yarn add replace-require-regex

Usage

const replaceRequireRegex = require('replace-require-regex');
 
replaceRequireRegex(`require('old')`, 'old', 'new');
//=> `require('new')`
 
replaceRequireRegex(`import a from 'old'`, 'old', 'new');
//=> `import a from 'new'`

API

replaceRequireRegex(content, from, to)

Arguments

Name Description Type Default
content Could be an entire file content string None
from old string to replace string None
to new string to replace old with string None

Returns

Type: string

License

MIT © Dawson Botsford

Readme

Keywords

none

Package Sidebar

Install

npm i replace-require-regex

Weekly Downloads

3

Version

1.1.0

License

MIT

Last publish

Collaborators

  • mager
  • rtsao
  • usiarhei
  • kenns29
  • shengs
  • emrahs
  • zacklk
  • uber-ospo
  • dawsonbotsford