https://github.com/cn-tower/gulp-edit-file
Edit file content in gulp pipe method. 一个在gulp的管道方法中修改文件内容的插件。
https://github.com/cn-tower/gulp-edit-file
gulp-edit gulp-edit-file gulp-editfile gulp-editor gulp-modify gulp-plugin-edit gulp-pugin
Last synced: 7 months ago
JSON representation
Edit file content in gulp pipe method. 一个在gulp的管道方法中修改文件内容的插件。
- Host: GitHub
- URL: https://github.com/cn-tower/gulp-edit-file
- Owner: CN-Tower
- License: mit
- Created: 2021-12-03T00:48:28.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-06T10:42:46.000Z (almost 4 years ago)
- Last Synced: 2025-02-25T01:31:38.464Z (7 months ago)
- Topics: gulp-edit, gulp-edit-file, gulp-editfile, gulp-editor, gulp-modify, gulp-plugin-edit, gulp-pugin
- Language: JavaScript
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-edit-file
[](https://www.npmjs.com/package/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;
```