Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function ResourceFile(directory, filename, outputDirectory, statCache) {
if (!filename) { throw new Error("Expected a filename"); }
this.sourcePath = path.resolve(directory.src, filename);
this.sourceDirectory = directory.src;
// a vinyl file records changes to the file's path -- the first path in the
// history is the location on disk, then we set the path to the target
// location
File.call(this, {
base: directory.src,
path: this.sourcePath,
stat: statCache && statCache[this.sourcePath]
});
this.sourceRelativePath = path.relative(this.sourceDirectory, this.sourcePath);
this.targetRelativePath = slash(path.join(directory.target, this.sourceRelativePath));
this.base = outputDirectory;
this.path = path.join(outputDirectory, this.targetRelativePath);
this._isStream = true;
}
var MetadataFile = module.exports = function(opts) {
File.call(this, opts);
};
this.options = item.options || {};
this.locals = item.locals || {};
this.data = item.data || {};
this.define('contents', {
configurable: true,
enumerable: false,
set: function(val) {
utils.syncContents(this, val);
},
get: function() {
return this._contents;
}
});
Vinyl.call(this, item);
var base = this.base;
delete item.base;
Base.call(this, item);
delete this.base;
this.base = base;
for (var key in item) {
var val = item[key];
if (key === 'stat' && utils.isObject(val) && val.mode) {
this.set(key, utils.cloneStats(val));
} else if (val) {
this.set(key, val);
}
}