# gulp-edit-file

> Edit file content in gulp pipe method. 一个在gulp的管道方法中修改文件内容的插件。

Latest version **1.0.3** (published 2021-12-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-edit-file
pnpm add gulp-edit-file
yarn add gulp-edit-file
bun add gulp-edit-file
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-12-03 |
| First published | 2021-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | cntower |
| Keywords | gulp-edit-file, gulp-file-editor, gulp-eidt, gulp-modify, gulp-change, gulp-plugin |

## Links

- npm: https://www.npmjs.com/package/gulp-edit-file
- Repository: https://github.com/CN-Tower/gulp-edit-file
- Homepage: https://github.com/CN-Tower/gulp-edit-file#readme
- Issues: https://github.com/CN-Tower/gulp-edit-file/issues
- npm.io page: https://npm.io/package/gulp-edit-file

## Dependencies (2)

- [through2](https://npm.io/package/through2.md) ^4.0.2
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.8

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-12-03
- 1.0.2 — 2021-12-03
- 1.0.1 — 2021-12-03
- 1.0.0 — 2021-12-03

## README

# gulp-edit-file

> Edit file content in gulp pipe method.
> 一个在gulp的管道方法中修改文件内容的插件。

## Install
```
npm install gulp-edit-file -D
```

## Gulp Demo
```js
const gulp = require('gulp');
const editFile = require('gulp-edit-file');

gulp.task('edit', () => {
  return gulp
    .src('src/index.js')
    .pipe(editFile((content, fileInfo) => {
      console.log(fileInfo);
      // Edit file content here, eg:
      const newContent = `/*!\n * Hello there!\n */${content}`;
      return newContent;
    }))
    .pipe(gulp.dest('dist'));
});
```

## Result
src/index.js
```js
console.log('index.js');
```
To ↓ ↓ ↓ ↓ ↓ ↓

dist/index.js
```js
/*!
 * Hello there!
 */
console.log('index.js');
```

## Interface
```ts
interface FileInfo {
  dirName: string,
  dirPath: string,
  fileBase: string,
  fileExt: string,
  fileName: string,
  filePath: string,
}
declare function editFile(handler: (content: string, fileInfo: FileInfo) => string): NodeJS.ReadWriteStream;
export = editFile;
```

---
_Source: https://npm.io/package/gulp-edit-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
