JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 567
  • Score
    100M100P100Q95276F
  • License Apache-2.0

File system operations related utilities based on fs-extra

Package Exports

  • @handy-common-utils/fs-utils
  • @handy-common-utils/fs-utils/dist/fs-utils.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@handy-common-utils/fs-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@handy-common-utils/fs-utils

File system operations related utilities without any 3rd party dependency.

Version Downloads/week CI codecov

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

Generated using TypeDoc