DEV Community

rabbitzzc
rabbitzzc

Posted on

tiny-replace-files

recommend: https://github.com/Rabbitzzc/tiny-replace-files

import { replaceStringInFilesSync } from 'tiny-replace-files'

const options = {
  files: 'src/targets/index.js',
  from: 'test-plugin',
  to: 'self-name',
}

# await
const result = replaceStringInFilesSync(options)
console.info(result)
/**
[
  {
    file: './ques2.md',
    changed: true,
    matchCounts: 1,
    replaceCounts: 1
  }
]
*/
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
rabbitzzc profile image
rabbitzzc

It's useful, and very tiny....