@jswork/next-replace-in-file
v1.0.0
Published
File content replace for next.
Downloads
12
Maintainers
Readme
next-replace-in-file
File content replace for next.
installation
npm install -S @jswork/next-replace-in-file
usage
Basic usage.
import '@feizheng/next-replace-in-file';
// basic usage:
nx.replaceInFile('test/**', [[/VERSION/gi, 'version']]);
nx.replaceInFile(['**','!node_modules'], [[/VERSION/gi, 'version']]);
// or you can multiple replace:
nx.replaceInFile(
'test/**',
[
[/VERSION/gi, '_VERSION_'],
[/file/g, 'FILE'],
[/description/g,'DESC'],
],
{
ignore: ['*/test.js']
}
);
globby
Just a quick overview.
*
matches any number of characters, but not/
?
matches a single character, but not/
**
matches any number of characters, including/
, as long as it's the only thing in a path part{}
allows for a comma-separated list of "or" expressions!
at the beginning of a pattern will negate the match
options
Not fully, because
fast-glob
does not implement all options ofnode-glob
. See table below.
| node-glob(😂) | fast-glob(😎) |
| :----------: | :---------------------------------------------------------: |
| cwd
| cwd
|
| root
| – |
| dot
| dot
|
| nomount
| – |
| mark
| markDirectories
|
| nosort
| – |
| nounique
| unique
|
| nobrace
| nobrace
or brace
|
| noglobstar
| noglobstar
or globstar
|
| noext
| noext
or extension
|
| nocase
| nocase
or case
|
| matchBase
| matchbase
|
| nodir
| onlyFiles
|
| ignore
| ignore
|
| follow
| followSymlinkedDirectories
|
| realpath
| – |
| absolute
| absolute
|
resources
- https://github.com/afeiship/next-array-replace
- https://github.com/sindresorhus/globby
- https://github.com/mrmlnc/fast-glob#options-1
license
Code released under the MIT license.