replace-require-regex
v1.1.0
Published
regex based require/import replacements for js files
Downloads
3
Keywords
Readme
replace-require-regex
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