@jswork/next-replace-in-file

File content replace for next.

Usage no npm install needed!

<script type="module">
  import jsworkNextReplaceInFile from 'https://cdn.skypack.dev/@jswork/next-replace-in-file';
</script>

README

next-replace-in-file

File content replace for next.

version license size download

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 of node-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

license

Code released under the MIT license.