Initial commit
[yaffs-website] / node_modules / gulp / node_modules / vinyl-fs / README.md
1 # vinyl-fs [![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-fs)
2
3 ## Information
4
5 <table>
6 <tr>
7 <td>Package</td><td>vinyl-fs</td>
8 </tr>
9 <tr>
10 <td>Description</td>
11 <td>Vinyl adapter for the file system</td>
12 </tr>
13 <tr>
14 <td>Node Version</td>
15 <td>>= 0.10</td>
16 </tr>
17 </table>
18
19 ## Usage
20
21 ```javascript
22 var map = require('map-stream');
23 var fs = require('vinyl-fs');
24
25 var log = function(file, cb) {
26   console.log(file.path);
27   cb(null, file);
28 };
29
30 fs.src(['./js/**/*.js', '!./js/vendor/*.js'])
31   .pipe(map(log))
32   .pipe(fs.dest('./output'));
33 ```
34
35 ## API
36
37 ### src(globs[, opt])
38
39 - Takes a glob string or an array of glob strings as the first argument.
40 - Possible options for the second argument:
41   - cwd - Specify the working directory the folder is relative to. Default is `process.cwd()`
42   - base - Specify the folder relative to the cwd. Default is where the glob begins. This is used to determine the file names when saving in `.dest()`
43   - buffer - `true` or `false` if you want to buffer the file.
44     - Default value is `true`
45     - `false` will make file.contents a paused Stream
46   - read - `true` or `false` if you want the file to be read or not. Useful for stuff like `rm`ing files.
47     - Default value is `true`
48     - `false` will disable writing the file to disk via `.dest()`
49   - Any glob-related options are documented in [glob-stream] and [node-glob]
50 - Returns a Readable/Writable stream.
51 - On write the stream will simply pass items through.
52 - This stream emits matching [vinyl] File objects
53
54 ### watch(globs[, opt, cb])
55
56 This is just [glob-watcher]
57
58 - Takes a glob string or an array of glob strings as the first argument.
59 - Possible options for the second argument:
60   - Any options are passed to [gaze]
61 - Returns an EventEmitter
62   - 'changed' event is emitted on each file change
63 - Optionally calls the callback on each change event
64
65 ### dest(folder[, opt])
66
67 - Takes a folder path as the first argument.
68 - First argument can also be a function that takes in a file and returns a folder path.
69 - Possible options for the second argument:
70   - cwd - Specify the working directory the folder is relative to. Default is `process.cwd()`
71   - mode - Specify the mode the files should be created with. Default is the mode of the input file (file.stat.mode)
72 - Returns a Readable/Writable stream.
73 - On write the stream will save the [vinyl] File to disk at the folder/cwd specified.
74 - After writing the file to disk, it will be emitted from the stream so you can keep piping these around
75 - The file will be modified after being written to this stream
76   - `cwd`, `base`, and `path` will be overwritten to match the folder
77   - `stat.mode` will be overwritten if you used a mode parameter
78   - `contents` will have it's position reset to the beginning if it is a stream
79
80 [glob-stream]: https://github.com/wearefractal/glob-stream
81 [node-glob]: https://github.com/isaacs/node-glob
82 [gaze]: https://github.com/shama/gaze
83 [glob-watcher]: https://github.com/wearefractal/glob-watcher
84 [vinyl]: https://github.com/wearefractal/vinyl
85
86 [npm-url]: https://npmjs.org/package/vinyl-fs
87 [npm-image]: https://badge.fury.io/js/vinyl-fs.png
88 [travis-url]: https://travis-ci.org/wearefractal/vinyl-fs
89 [travis-image]: https://travis-ci.org/wearefractal/vinyl-fs.png?branch=master
90 [coveralls-url]: https://coveralls.io/r/wearefractal/vinyl-fs
91 [coveralls-image]: https://coveralls.io/repos/wearefractal/vinyl-fs/badge.png
92 [depstat-url]: https://david-dm.org/wearefractal/vinyl-fs
93 [depstat-image]: https://david-dm.org/wearefractal/vinyl-fs.png