gulp-edit-file
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

gulp-edit-file

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

Install

npm install gulp-edit-file -D

Gulp Demo

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

console.log('index.js');

To ↓ ↓ ↓ ↓ ↓ ↓

dist/index.js

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

Interface

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;

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    12
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    12
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i gulp-edit-file

Weekly Downloads

12

Version

1.0.3

License

MIT

Unpacked Size

5.15 kB

Total Files

10

Last publish

Collaborators

  • cntower