Closed colynb closed 10 years ago
The entire file object is data though. How is this better than
var srcFile = new gutil.File({
path: "test/fixtures/filepath.txt",
cwd: "test/",
base: "test/fixtures",
contents: new Buffer("Fake data")
});
srcFile.message = 'some data';
?
I was so focused on trying to attach the prop during instantiation I didn't even think about adding it after the fact. Closing request.
var srcFile = new gutil.File({
path: "test/fixtures/filepath.txt",
cwd: "test/",
base: "test/fixtures",
contents: new Buffer("Fake data"),
message1: "Hello"
});
srcFile.message2 = "World";
// srcFile.message1 === undefined
// srcFile.message2 === "World"
I'm developing a standard methodology for passing meta data to plugins using a separate plugin called
gulp-data
(see https://www.npmjs.org/package/gulp-data). It all works fine without this change, but when writing gulp plugin unit tests by instantiating a File object with the data property attached, the tests fail. It looks like setting a default value here fixes that. Now I can write tests on adhoc files: