问题描述
我已升级到 gulp const std::type_identity_t<T>& root
版本,我需要更新其中一项任务
4.0.2
我希望将这些文件转换为 Vinyl 对象:
const debug = require('gulp-debug');
const i18nextParser = require('i18next-parser');
function myTask() {
return gulp
.src(['./js/**/*.js','./js/**/*.jsx'])
.pipe(
i18nextParser({
locales: ['en','de'],functions: ['translate'],output: '/opt/locales/'
})
)
.pipe(debug())
.pipe(gulp.dest('/opt/locales/'));
});
[17:04:32] gulp-debug: opt/locales/de/translation.json
[17:04:32] gulp-debug: opt/locales/de/translation_old.json
[17:04:32] gulp-debug: opt/locales/en/translation.json
[17:04:32] gulp-debug: opt/locales/en/translation_old.json
是否有我可以通过管道传输的函数以使此任务正常工作?
Error: Received a non-Vinyl object in `dest()`
版本是 i18next-parser
。升级到最新的 0.7.0
版本根本不会产生任何输出。
解决方法
所以我通过使用 gulp-map
添加额外的步骤解决了这个问题const map = require('gulp-map');
const Vinyl = require('vinyl');
return gulp
.src(['./js/*.js','./js/*.jsx'])
.pipe(
i18nextParser({
locales: ['en','de'],functions: ['translate'],output: JSON_DIR
})
)
.pipe(map(function(file) {
// Explicitly convert to Vinyl object otherwise `gulp.dest()` will fail
return new Vinyl(file);
}))
.pipe(gulp.dest(JSON_DIR));