Closed froddd closed 6 years ago
The file
there is a Vinyl file object, though.
When the tests are run, file
is a Vinyl object. The file
passed from through2
isn't.
$ npm install gulp through2 vinyl
$ echo '<h1>test</h1>' > template.html
gulpfile.js:
const gulp = require('gulp');
const through = require('through2');
const vinyl = require('vinyl');
gulp.task('default', () =>
gulp.src('template.html')
.pipe(through.obj(function (file, enc, cb) {
console.log('File is Vinyl:', vinyl.isVinyl(file))
cb(null, file)
}))
);
$ gulp
[14:02:24] Using gulpfile ~/test-nunjucks/gulpfile.js
[14:02:24] Starting 'default'...
File is Vinyl: false
[14:02:24] Finished 'default' after 20 ms
Returns a stream of Vinyl files that can be piped to plugins. - https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpsrcglobs-options
The problem is that Vinyl is outdated in Gulp v3.
I've fixed this in a patch release.
setting
file.extname = '.js'
seems to only work on Vinyl file objects, meaning tests are passing but precompiling produces.html
files when run on actual templates. Updating the file path using the Nodepath
module works on all files.