Initial commit
[yaffs-website] / node_modules / gulp / node_modules / vinyl / README.md
1 # 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)
2
3
4 ## Information
5
6 <table>
7 <tr> 
8 <td>Package</td><td>vinyl</td>
9 </tr>
10 <tr>
11 <td>Description</td>
12 <td>A virtual file format</td>
13 </tr>
14 <tr>
15 <td>Node Version</td>
16 <td>>= 0.9</td>
17 </tr>
18 </table>
19
20 ## What is this?
21
22 Read this for more info about how this plays into the grand scheme of things https://medium.com/@eschoff/3828e8126466
23
24 ## File
25
26 ```javascript
27 var File = require('vinyl');
28
29 var coffeeFile = new File({
30   cwd: "/",
31   base: "/test/",
32   path: "/test/file.coffee",
33   contents: new Buffer("test = 123")
34 });
35 ```
36
37 ### constructor(options)
38
39 #### options.cwd
40
41 Type: `String`  
42 Default: `process.cwd()`
43
44 #### options.base
45
46 Used for relative pathing. Typically where a glob starts.
47
48 Type: `String`  
49 Default: `options.cwd`
50
51 #### options.path
52
53 Full path to the file.
54
55 Type: `String`  
56 Default: `null`
57
58 #### options.stat
59
60 The result of an fs.stat call. See [fs.Stats](http://nodejs.org/api/fs.html#fs_class_fs_stats) for more information.
61
62 Type: `fs.Stats`  
63 Default: `null`
64
65 #### options.contents
66
67 File contents.
68
69 Type: `Buffer, Stream, or null`  
70 Default: `null`
71
72 ### isBuffer()
73
74 Returns true if file.contents is a Buffer.
75
76 ### isStream()
77
78 Returns true if file.contents is a Stream.
79
80 ### isNull()
81
82 Returns true if file.contents is null.
83
84 ### clone()
85
86 Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
87
88 ### pipe(stream[, opt])
89
90 If file.contents is a Buffer, it will write it to the stream.
91
92 If file.contents is a Stream, it will pipe it to the stream.
93
94 If file.contents is null, it will do nothing.
95
96 If opt.end is false, the destination stream will not be ended (same as node core).
97
98 Returns the stream.
99
100 ### inspect()
101
102 Returns a pretty String interpretation of the File. Useful for console.log.
103
104 ### relative
105
106 Returns path.relative for the file base and file path.
107
108 Example:
109
110 ```javascript
111 var file = new File({
112   cwd: "/",
113   base: "/test/",
114   path: "/test/file.coffee"
115 });
116
117 console.log(file.relative); // file.coffee
118 ```
119
120 [npm-url]: https://npmjs.org/package/vinyl
121 [npm-image]: https://badge.fury.io/js/vinyl.png
122 [travis-url]: https://travis-ci.org/wearefractal/vinyl
123 [travis-image]: https://travis-ci.org/wearefractal/vinyl.png?branch=master
124 [coveralls-url]: https://coveralls.io/r/wearefractal/vinyl
125 [coveralls-image]: https://coveralls.io/repos/wearefractal/vinyl/badge.png
126 [depstat-url]: https://david-dm.org/wearefractal/vinyl
127 [depstat-image]: https://david-dm.org/wearefractal/vinyl.png