Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@handy-common-utils/fs-utils

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@handy-common-utils/fs-utils - npm Package Compare versions

Comparing version 1.0.5 to 1.0.8

6

dist/fs-utils.d.ts

@@ -21,3 +21,3 @@ /// <reference types="node" />

* @param filePath path to the file
* @param matchPattern RegExp for deciding which section of the file would be replaced. You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?`
* @param matchPattern RegExp for deciding which section of the file would be replaced. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?`
* @param replacementOrBuilder The replacement string or a function for building the replacement string.

@@ -34,3 +34,3 @@ * Please note that you can use special replacement patterns but also you need to take care of the escaping.

* You must have a capturing group in the pattern.
* You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?`
* You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?`
* @param addBefore the string to be added before the capturing group, no need to escape anything

@@ -46,3 +46,3 @@ * @param addAfter the string to be added before the capturing group, no need to escape anything

* You must have a capturing group in the pattern.
* You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?`
* You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?`
* @param contentFilePath path of the file for getting the replacement content

@@ -49,0 +49,0 @@ * @param fileEncoding encoding of the files

@@ -32,3 +32,3 @@ "use strict";

* @param filePath path to the file
* @param matchPattern RegExp for deciding which section of the file would be replaced. You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?`
* @param matchPattern RegExp for deciding which section of the file would be replaced. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?`
* @param replacementOrBuilder The replacement string or a function for building the replacement string.

@@ -48,3 +48,3 @@ * Please note that you can use special replacement patterns but also you need to take care of the escaping.

* You must have a capturing group in the pattern.
* You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?`
* You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?`
* @param addBefore the string to be added before the capturing group, no need to escape anything

@@ -62,3 +62,3 @@ * @param addAfter the string to be added before the capturing group, no need to escape anything

* You must have a capturing group in the pattern.
* You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?`
* You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?`
* @param contentFilePath path of the file for getting the replacement content

@@ -65,0 +65,0 @@ * @param fileEncoding encoding of the files

{
"name": "@handy-common-utils/fs-utils",
"version": "1.0.5",
"version": "1.0.8",
"description": "File system operations related utilities based on fs-extra",

@@ -5,0 +5,0 @@ "scripts": {

@@ -16,11 +16,17 @@ # @handy-common-utils/fs-utils

```javascript
import { FsUtils } from '../fs-utils';
import { FsUtils } from 'fs-utils';
const [,, filePath, matchPattern, beforeString, afterString] = process.argv;
FsUtils.addSurrounding(filePath, new RegExp(matchPattern), beforeString, afterString);
await FsUtils.addSurroundingInFile(filePath, new RegExp(matchPattern), beforeString, afterString);
```
You can either import and use the [class](#classes) as shown above,
or you can import individual [functions](#variables) directly.
or you can import individual [functions](#variables) directly like below:
```javascript
import { addSurroundingInFile } from 'fs-utils';
await addSurroundingInFile(README_MD_FILE, /<example>(.*?)<\/example>/gms, '<example><b>', '</b></example>');
```
# API

@@ -154,3 +160,3 @@

`filePath` | string | - | path to the file |
`matchPattern` | RegExp | - | RegExp for deciding which section of the file would be processed. You must have a capturing group in the pattern. You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?` |
`matchPattern` | RegExp | - | RegExp for deciding which section of the file would be processed. You must have a capturing group in the pattern. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?` |
`addBefore` | string | - | the string to be added before the capturing group, no need to escape anything |

@@ -215,3 +221,3 @@ `addAfter` | string | - | the string to be added before the capturing group, no need to escape anything |

`filePath` | string | - | path to the file |
`matchPattern` | RegExp | - | RegExp for deciding which section of the file would be replaced. You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?` |
`matchPattern` | RegExp | - | RegExp for deciding which section of the file would be replaced. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?` |
`replacementOrBuilder` | string \| (matchPattern: RegExp, filePath: string) => string \| PromiseLike\<string> | - | The replacement string or a function for building the replacement string. Please note that you can use special replacement patterns but also you need to take care of the escaping. For details of special replacement patterns see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace |

@@ -235,3 +241,3 @@ `fileEncoding` | Parameters\<Buffer[\"toString\"]>[\"0\"] | "utf-8" | encoding of the file |

`filePath` | string | - | path of the file |
`matchPattern` | RegExp | - | RegExp for deciding which section of the file would be replaced. You must have a capturing group in the pattern. You may want to use these tricks: `m` flag, `g` flag, `[\s\S]*`, `.*?` |
`matchPattern` | RegExp | - | RegExp for deciding which section of the file would be replaced. You must have a capturing group in the pattern. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?` |
`contentFilePath` | string | - | path of the file for getting the replacement content |

@@ -238,0 +244,0 @@ `fileEncoding` | Parameters\<Buffer[\"toString\"]>[\"0\"] | "utf-8" | encoding of the files |

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc