Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vinyl

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vinyl - npm Package Compare versions

Comparing version 2.2.1 to 3.0.0

119

index.js

@@ -5,9 +5,8 @@ 'use strict';

var util = require('util');
var isBuffer = require('buffer').Buffer.isBuffer;
var Buffer = require('buffer').Buffer;
var clone = require('clone');
var cloneable = require('cloneable-readable');
var teex = require('teex');
var replaceExt = require('replace-ext');
var cloneStats = require('clone-stats');
var cloneBuffer = require('clone-buffer');
var removeTrailingSep = require('remove-trailing-separator');

@@ -20,4 +19,12 @@

var builtInFields = [
'_contents', '_symlink', 'contents', 'stat', 'history', 'path',
'_base', 'base', '_cwd', 'cwd',
'_contents',
'_symlink',
'contents',
'stat',
'history',
'path',
'_base',
'base',
'_cwd',
'cwd',
];

@@ -44,3 +51,3 @@

this.history = [];
history.forEach(function(path) {
history.forEach(function (path) {
self.path = path;

@@ -57,3 +64,3 @@ });

// Set custom properties
Object.keys(file).forEach(function(key) {
Object.keys(file).forEach(function (key) {
if (self.constructor.isCustomProp(key)) {

@@ -65,15 +72,15 @@ self[key] = file[key];

File.prototype.isBuffer = function() {
return isBuffer(this.contents);
File.prototype.isBuffer = function () {
return Buffer.isBuffer(this.contents);
};
File.prototype.isStream = function() {
File.prototype.isStream = function () {
return isStream(this.contents);
};
File.prototype.isNull = function() {
return (this.contents === null);
File.prototype.isNull = function () {
return this.contents === null;
};
File.prototype.isDirectory = function() {
File.prototype.isDirectory = function () {
if (!this.isNull()) {

@@ -90,3 +97,3 @@ return false;

File.prototype.isSymbolic = function() {
File.prototype.isSymbolic = function () {
if (!this.isNull()) {

@@ -103,3 +110,3 @@ return false;

File.prototype.clone = function(opt) {
File.prototype.clone = function (opt) {
var self = this;

@@ -125,5 +132,7 @@

if (this.isStream()) {
contents = this.contents.clone();
var streams = teex(this._contents);
this._contents = streams[0];
contents = streams[1];
} else if (this.isBuffer()) {
contents = opt.contents ? cloneBuffer(this.contents) : this.contents;
contents = opt.contents ? Buffer.from(this.contents) : this.contents;
}

@@ -134,3 +143,3 @@

base: this.base,
stat: (this.stat ? cloneStats(this.stat) : null),
stat: this.stat ? cloneStats(this.stat) : null,
history: this.history.slice(),

@@ -145,3 +154,3 @@ contents: contents,

// Clone our custom properties
Object.keys(this).forEach(function(key) {
Object.keys(this).forEach(function (key) {
if (self.constructor.isCustomProp(key)) {

@@ -154,3 +163,4 @@ file[key] = opt.deep ? clone(self[key], true) : self[key];

File.prototype.inspect = function() {
// Node.js v6.6.0+ use this symbol for custom inspection.
File.prototype[util.inspect.custom] = function () {
var inspect = [];

@@ -176,12 +186,7 @@

// Newer Node.js versions use this symbol for custom inspection.
if (util.inspect.custom) {
File.prototype[util.inspect.custom] = File.prototype.inspect;
}
File.isCustomProp = function(key) {
File.isCustomProp = function (key) {
return builtInFields.indexOf(key) === -1;
};
File.isVinyl = function(file) {
File.isVinyl = function (file) {
return (file && file._isVinyl === true) || false;

@@ -193,17 +198,10 @@ };

Object.defineProperty(File.prototype, 'contents', {
get: function() {
get: function () {
return this._contents;
},
set: function(val) {
if (!isBuffer(val) && !isStream(val) && (val !== null)) {
set: function (val) {
if (!Buffer.isBuffer(val) && !isStream(val) && val !== null) {
throw new Error('File.contents can only be a Buffer, a Stream, or null.');
}
// Ask cloneable if the stream is a already a cloneable
// this avoid piping into many streams
// reducing the overhead of cloning
if (isStream(val) && !cloneable.isCloneable(val)) {
val = cloneable(val);
}
this._contents = val;

@@ -214,6 +212,6 @@ },

Object.defineProperty(File.prototype, 'cwd', {
get: function() {
get: function () {
return this._cwd;
},
set: function(cwd) {
set: function (cwd) {
if (!cwd || typeof cwd !== 'string') {

@@ -227,6 +225,6 @@ throw new Error('cwd must be a non-empty string.');

Object.defineProperty(File.prototype, 'base', {
get: function() {
get: function () {
return this._base || this._cwd;
},
set: function(base) {
set: function (base) {
if (base == null) {

@@ -250,3 +248,3 @@ delete this._base;

Object.defineProperty(File.prototype, 'relative', {
get: function() {
get: function () {
if (!this.path) {

@@ -257,4 +255,6 @@ throw new Error('No path specified! Can not get relative.');

},
set: function() {
throw new Error('File.relative is generated from the base and path attributes. Do not modify it.');
set: function () {
throw new Error(
'File.relative is generated from the base and path attributes. Do not modify it.'
);
},

@@ -264,3 +264,3 @@ });

Object.defineProperty(File.prototype, 'dirname', {
get: function() {
get: function () {
if (!this.path) {

@@ -271,3 +271,3 @@ throw new Error('No path specified! Can not get dirname.');

},
set: function(dirname) {
set: function (dirname) {
if (!this.path) {

@@ -281,3 +281,3 @@ throw new Error('No path specified! Can not set dirname.');

Object.defineProperty(File.prototype, 'basename', {
get: function() {
get: function () {
if (!this.path) {

@@ -288,3 +288,3 @@ throw new Error('No path specified! Can not get basename.');

},
set: function(basename) {
set: function (basename) {
if (!this.path) {

@@ -299,3 +299,3 @@ throw new Error('No path specified! Can not set basename.');

Object.defineProperty(File.prototype, 'stem', {
get: function() {
get: function () {
if (!this.path) {

@@ -306,3 +306,3 @@ throw new Error('No path specified! Can not get stem.');

},
set: function(stem) {
set: function (stem) {
if (!this.path) {

@@ -316,3 +316,3 @@ throw new Error('No path specified! Can not set stem.');

Object.defineProperty(File.prototype, 'extname', {
get: function() {
get: function () {
if (!this.path) {

@@ -323,3 +323,3 @@ throw new Error('No path specified! Can not get extname.');

},
set: function(extname) {
set: function (extname) {
if (!this.path) {

@@ -333,6 +333,11 @@ throw new Error('No path specified! Can not set extname.');

Object.defineProperty(File.prototype, 'path', {
get: function() {
return this.history[this.history.length - 1];
get: function () {
var path = this.history[this.history.length - 1];
if (path) {
return path;
} else {
return null;
}
},
set: function(path) {
set: function (path) {
if (typeof path !== 'string') {

@@ -351,6 +356,6 @@ throw new Error('path should be a string.');

Object.defineProperty(File.prototype, 'symlink', {
get: function() {
get: function () {
return this._symlink;
},
set: function(symlink) {
set: function (symlink) {
// TODO: should this set the mode to symbolic if set?

@@ -357,0 +362,0 @@ if (typeof symlink !== 'string') {

{
"name": "vinyl",
"version": "2.2.1",
"version": "3.0.0",
"description": "Virtual file format.",

@@ -13,3 +13,3 @@ "author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",

"engines": {
"node": ">= 0.10"
"node": ">=10.13.0"
},

@@ -25,24 +25,30 @@ "main": "index.js",

"pretest": "npm run lint",
"test": "nyc mocha --async-only",
"azure-pipelines": "nyc mocha --async-only --reporter xunit -O output=test.xunit",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
"test": "nyc mocha --async-only"
},
"dependencies": {
"clone": "^2.1.1",
"clone-buffer": "^1.0.0",
"clone": "^2.1.2",
"clone-stats": "^1.0.0",
"cloneable-readable": "^1.0.0",
"remove-trailing-separator": "^1.0.1",
"replace-ext": "^1.0.0"
"remove-trailing-separator": "^1.1.0",
"replace-ext": "^2.0.0",
"teex": "^1.0.1"
},
"devDependencies": {
"coveralls": "github:phated/node-coveralls#2.x",
"eslint": "^2.13.1",
"eslint-config-gulp": "^3.0.1",
"expect": "^1.20.2",
"mississippi": "^1.2.0",
"mocha": "^3.0.0",
"nyc": "^10.3.2",
"safer-buffer": "^2.1.2"
"eslint": "^7.32.0",
"eslint-config-gulp": "^5.0.1",
"eslint-plugin-node": "^11.1.0",
"expect": "^27.4.6",
"mocha": "^8.4.0",
"nyc": "^15.1.0",
"readable-stream": "^3.6.0",
"streamx": "^2.12.5"
},
"nyc": {
"reporter": [
"lcov",
"text-summary"
]
},
"prettier": {
"singleQuote": true
},
"keywords": [

@@ -49,0 +55,0 @@ "virtual",

<p align="center">
<a href="http://gulpjs.com">
<a href="https://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">

@@ -9,3 +9,3 @@ </a>

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Azure Pipelines Build Status][azure-pipelines-image]][azure-pipelines-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]

@@ -31,3 +31,3 @@ Virtual file format.

path: '/test/file.js',
contents: Buffer.from('var x = 123')
contents: Buffer.from('var x = 123'),
});

@@ -92,3 +92,3 @@ ```

The contents of the file. If `options.contents` is a [`ReadableStream`][readable-stream], it is wrapped in a [`cloneable-readable`][cloneable-readable] stream.
The contents of the file. If `options.contents` is a [`ReadableStream`][readable-stream], it is wrapped in a [`cloneable-readable`][cloneable-readable] stream.

@@ -154,3 +154,3 @@ Type: [`ReadableStream`][readable-stream], [`Buffer`][buffer], or `null`

__By default custom attributes are cloned deeply.__
**By default custom attributes are cloned deeply.**

@@ -222,3 +222,3 @@ If `options` or `options.deep` is `false`, custom attributes will not be cloned deeply.

base: '/test/',
path: '/test/file.js'
path: '/test/file.js',
});

@@ -243,3 +243,3 @@

base: '/test/',
path: '/test/file.js'
path: '/test/file.js',
});

@@ -269,3 +269,3 @@

base: '/test/',
path: '/test/file.js'
path: '/test/file.js',
});

@@ -295,3 +295,3 @@

base: '/test/',
path: '/test/file.js'
path: '/test/file.js',
});

@@ -321,3 +321,3 @@

base: '/test/',
path: '/test/file.js'
path: '/test/file.js',
});

@@ -347,3 +347,3 @@

__Note: This method uses an internal flag that some older versions of Vinyl didn't expose.__
**Note: This method uses an internal flag that some older versions of Vinyl didn't expose.**

@@ -423,6 +423,6 @@ Example:

// `foo` won't be assigned to the object below
new SuperFile({ foo: "something" });
new SuperFile({ foo: 'something' });
```
This makes properties `foo` and `_foo` skipped when passed in options to `constructor(options)` so they don't get assigned to the new object and override your custom implementation. They also won't be copied when cloning. __Note:__ The `_foo` and `foo` properties will still exist on the created/cloned object because you are assigning `_foo` in the constructor and `foo` is defined on the prototype.
This makes properties `foo` and `_foo` skipped when passed in options to `constructor(options)` so they don't get assigned to the new object and override your custom implementation. They also won't be copied when cloning. **Note:** The `_foo` and `foo` properties will still exist on the created/cloned object because you are assigning `_foo` in the constructor and `foo` is defined on the prototype.

@@ -435,2 +435,15 @@ Same goes for `clone()`. If you have your own internal stuff that needs special handling during cloning, you should extend it to do so.

<!-- prettier-ignore-start -->
[downloads-image]: https://img.shields.io/npm/dm/vinyl.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/vinyl
[npm-image]: https://img.shields.io/npm/v/vinyl.svg?style=flat-square
[ci-url]: https://github.com/gulpjs/vinyl/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/vinyl/dev?style=flat-square
[coveralls-url]: https://coveralls.io/r/gulpjs/vinyl
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/vinyl/master.svg?style=flat-square
<!-- prettier-ignore-end -->
<!-- prettier-ignore-start -->
[is-symbolic]: #issymbolic

@@ -443,23 +456,5 @@ [is-directory]: #isdirectory

[buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer
[fs-stats]: http://nodejs.org/api/fs.html#fs_class_fs_stats
[fs-stats]: https://nodejs.org/api/fs.html#fs_class_fs_stats
[vinyl-fs]: https://github.com/gulpjs/vinyl-fs
[cloneable-readable]: https://github.com/mcollina/cloneable-readable
[downloads-image]: https://img.shields.io/npm/dm/vinyl.svg
[npm-url]: https://www.npmjs.com/package/vinyl
[npm-image]: https://img.shields.io/npm/v/vinyl.svg
[azure-pipelines-url]: https://dev.azure.com/gulpjs/gulp/_build/latest?definitionId=$PROJECT_ID&branchName=master
[azure-pipelines-image]: https://dev.azure.com/gulpjs/gulp/_apis/build/status/vinyl?branchName=master
[travis-url]: https://travis-ci.org/gulpjs/vinyl
[travis-image]: https://img.shields.io/travis/gulpjs/vinyl.svg?label=travis-ci
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/vinyl
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/vinyl.svg?label=appveyor
[coveralls-url]: https://coveralls.io/r/gulpjs/vinyl
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/vinyl/master.svg
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg
<!-- prettier-ignore-end -->

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc