Gulp 向特定文件添加一个新行的任务

Gulp task for add one new line to particular file

如何使用 gulp 任务向所需文件添加一行?

这是我的文件:

export { NumericTextBoxComponent} from './numerictextbox/numerictextbox.component';
export { NumericTextBoxModule } from './numerictextbox/numerictextbox.module';
export { NumericTextBoxAllModule } from './numerictextbox/numerictextbox-all.module';
export * from '@syncfusion/ej2-inputs';

在这里我想添加一行:

export { EJsvalidator} from './form-validator/form-validator';

我该怎么办?

我这样试过:

var footer = require('gulp-footer');
gulp.task('add', function() {
    return gulp.src('./third-party/angular/src/index.ts')
           .pipe(footer("export { EJsvalidator} from './form-validator/form-validator';"))
           .pipe(gulp.dest('./third-party/angular/src/index.ts'));
});

If i execute this task, it shows following error:

PS D:\ej2-input-component> gulp add
[14:29:09] Using gulpfile D:\ej2-input-component\gulpfile.js
[14:29:09] Starting 'add'...
[14:29:09] 'add' errored after 15 ms
[14:29:09] Error: EEXIST: file already exists, mkdir 'D:\ej2-input-component\third-party\angular\src\index.ts'
PS D:\ej2-input-component>

文档显示 gulp.dest('./dist/'),所以也许可以尝试 gulp.dest('./third-party/angular/src/')

另外,关于您的评论:

one more small pblm , i want to add it into next line but it is adding continues of last line

是的,这就是gulp-footer的重点,made在页脚中添加行,也就是在文件末尾:)还有更多灵活的模块,例如 gulp-insert-lines.