@feizheng/next-replace-in-file

1.0.2 • Public • Published

next-replace-in-file

File content replace for next.

version license size download

installation

npm install -S @feizheng/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.

Package Sidebar

Install

npm i @feizheng/next-replace-in-file

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

8.21 kB

Total Files

5

Last publish

Collaborators

  • afeiship