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 0.4.6 to 0.5.0

34

index.js

@@ -10,2 +10,3 @@ var path = require('path');

var Stream = require('stream');
var replaceExt = require('replace-ext');

@@ -162,2 +163,35 @@ function File(file) {

Object.defineProperty(File.prototype, 'dirname', {
get: function() {
if (!this.path) throw new Error('No path specified! Can not get dirname.');
return path.dirname(this.path);
},
set: function(dirname) {
if (!this.path) throw new Error('No path specified! Can not set dirname.');
this.path = path.join(dirname, path.basename(this.path));
}
});
Object.defineProperty(File.prototype, 'basename', {
get: function() {
if (!this.path) throw new Error('No path specified! Can not get basename.');
return path.basename(this.path);
},
set: function(basename) {
if (!this.path) throw new Error('No path specified! Can not set basename.');
this.path = path.join(path.dirname(this.path), basename);
}
});
Object.defineProperty(File.prototype, 'extname', {
get: function() {
if (!this.path) throw new Error('No path specified! Can not get extname.');
return path.extname(this.path);
},
set: function(extname) {
if (!this.path) throw new Error('No path specified! Can not set extname.');
this.path = replaceExt(this.path, extname);
}
});
Object.defineProperty(File.prototype, 'path', {

@@ -164,0 +198,0 @@ get: function() {

33

package.json
{
"name": "vinyl",
"description": "A virtual file format",
"version": "0.4.6",
"version": "0.5.0",
"homepage": "http://github.com/wearefractal/vinyl",

@@ -14,20 +14,20 @@ "repository": "git://github.com/wearefractal/vinyl.git",

"dependencies": {
"clone": "^0.2.0",
"clone-stats": "^0.0.1"
"clone": "^1.0.0",
"clone-stats": "^0.0.1",
"replace-ext": "0.0.1"
},
"devDependencies": {
"buffer-equal": "0.0.1",
"event-stream": "^3.1.0",
"istanbul": "^0.3.0",
"istanbul-coveralls": "^1.0.1",
"jshint": "^2.4.1",
"lodash.templatesettings": "^3.1.0",
"mocha": "^2.0.0",
"should": "^4.0.4",
"mocha-lcov-reporter": "^0.0.1",
"coveralls": "^2.6.1",
"istanbul": "^0.3.0",
"rimraf": "^2.2.5",
"jshint": "^2.4.1",
"buffer-equal": "0.0.1",
"lodash.templatesettings": "^2.4.1",
"event-stream": "^3.1.0"
"should": "^6.0.0"
},
"scripts": {
"test": "mocha --reporter spec && jshint lib",
"coveralls": "istanbul cover _mocha -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"
"test": "mocha && jshint lib",
"coveralls": "istanbul cover _mocha && istanbul-coveralls"
},

@@ -37,8 +37,3 @@ "engines": {

},
"licenses": [
{
"type": "MIT",
"url": "http://github.com/wearefractal/vinyl/raw/master/LICENSE"
}
]
"license": "MIT"
}

@@ -7,3 +7,3 @@ # vinyl [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status](https://david-dm.org/wearefractal/vinyl.png?theme=shields.io)](https://david-dm.org/wearefractal/vinyl)

<table>
<tr>
<tr>
<td>Package</td><td>vinyl</td>

@@ -42,3 +42,3 @@ </tr>

Type: `String`
Type: `String`<br>
Default: `process.cwd()`

@@ -50,3 +50,3 @@

Type: `String`
Type: `String`<br>
Default: `options.cwd`

@@ -58,5 +58,12 @@

Type: `String`
Default: `null`
Type: `String`<br>
Default: `undefined`
#### options.history
Path history. Has no effect if `options.path` is passed.
Type: `Array`<br>
Default: `options.path ? [options.path] : []`
#### options.stat

@@ -66,3 +73,3 @@

Type: `fs.Stats`
Type: `fs.Stats`<br>
Default: `null`

@@ -74,3 +81,3 @@

Type: `Buffer, Stream, or null`
Type: `Buffer, Stream, or null`<br>
Default: `null`

@@ -90,6 +97,11 @@

### clone()
### clone([opt])
Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
Returns a new File object with all attributes cloned.
By default custom attributes are deep-cloned.
If opt or opt.deep is false, custom attributes will not be deep-cloned.
If opt.contents is false, it will copy file.contents Buffer's reference.
### pipe(stream[, opt])

@@ -111,2 +123,10 @@

### path
Absolute pathname string or `undefined`. Setting to a different value pushes the old value to `history`.
### history
Array of `path` values the file object has had, from `history[0]` (original) through `history[history.length - 1]` (current). `history` and its elements should normally be treated as read-only and only altered indirectly by setting `path`.
### relative

@@ -128,2 +148,65 @@

### dirname
Gets and sets path.dirname for the file path.
Example:
```javascript
var file = new File({
cwd: "/",
base: "/test/",
path: "/test/file.coffee"
});
console.log(file.dirname); // /test
file.dirname = '/specs';
console.log(file.dirname); // /specs
console.log(file.path); // /specs/file.coffee
````
### basename
Gets and sets path.basename for the file path.
Example:
```javascript
var file = new File({
cwd: "/",
base: "/test/",
path: "/test/file.coffee"
});
console.log(file.basename); // file.coffee
file.basename = 'file.js';
console.log(file.basename); // file.js
console.log(file.path); // /test/file.js
````
### extname
Gets and sets path.extname for the file path.
Example:
```javascript
var file = new File({
cwd: "/",
base: "/test/",
path: "/test/file.coffee"
});
console.log(file.extname); // .coffee
file.extname = '.js';
console.log(file.extname); // .js
console.log(file.path); // /test/file.js
````
[npm-url]: https://npmjs.org/package/vinyl

@@ -130,0 +213,0 @@ [npm-image]: https://badge.fury.io/js/vinyl.png

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