1.0.0 • Published 5 years ago
@jswork/next-replace-in-file
Licence
MIT
Version
1.0.0
Deps
1
Size
8 kB
Vulns
0
Weekly
0
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-globdoes 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.