@handy-common-utils/fs-utils
File system operations related utilities without any 3rd party dependency.
![codecov](https://codecov.io/gh/handy-common-utils/fs-utils/branch/master/graph/badge.svg?token=W08QCZS9H1)
How to use
First add it as a dependency:
npm install @handy-common-utils/fs-utils
Then you can use it in the code:
import { FsUtils } from '@handy-common-utils/fs-utils';
const [,, filePath, matchPattern, beforeString, afterString] = process.argv;
await FsUtils.addSurroundingInFile(filePath, new RegExp(matchPattern), beforeString, afterString);
You can either import and use the class as shown above,
or you can import individual functions directly like below:
import { addSurroundingInFile } from 'fs-utils';
await addSurroundingInFile(README_MD_FILE, /<example>(.*?)<\/example>/gms, '<example><b>', '</b></example>');
There are also several commands you can use directly from your shell/build scripts:
- replace-in-file
filePath
matchPattern
replacement
- replace-in-files
matchPattern
replacement
file1
file2
file3
... - replace-in-file-with-file-content
filePath
matchPattern
contentFilePath
- add-surrounding-in-file
filePath
matchPattern
beforeString
afterString
API
fs-utils | @handy-common-utils/fs-utils