Comparing version 2.2.1 to 2.3.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
dest: require('./lib/dest'), | ||
symlink: require('./lib/symlink') | ||
symlink: require('./lib/symlink'), | ||
}; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var duplexify = require('duplexify'); | ||
var sink = require('../sink'); | ||
var prepareWrite = require('../prepareWrite'); | ||
@@ -24,11 +25,24 @@ var writeContents = require('./writeContents'); | ||
var saveStream = through2.obj(saveFile); | ||
var saveStream = through2.obj(opt, saveFile); | ||
if (!opt.sourcemaps) { | ||
// Sink the save stream to start flowing | ||
// Do this on nextTick, it will flow at slowest speed of piped streams | ||
process.nextTick(sink(saveStream)); | ||
return saveStream; | ||
} | ||
var mapStream = sourcemaps.write(opt.sourcemaps.path, opt.sourcemaps); | ||
var sourcemapOpt = opt.sourcemaps; | ||
if (typeof sourcemapOpt === 'boolean') { | ||
sourcemapOpt = { sourcemaps: sourcemapOpt }; | ||
} | ||
var mapStream = sourcemaps.write(sourcemapOpt.path, sourcemapOpt); | ||
var outputStream = duplexify.obj(mapStream, saveStream); | ||
mapStream.pipe(saveStream); | ||
// Sink the output stream to start flowing | ||
// Do this on nextTick, it will flow at slowest speed of piped streams | ||
process.nextTick(sink(outputStream)); | ||
return outputStream; | ||
@@ -35,0 +49,0 @@ } |
@@ -10,3 +10,3 @@ 'use strict'; | ||
function writeContents(writePath, file, cb) { | ||
// if directory then mkdirp it | ||
// If directory then mkdirp it | ||
if (file.isDirectory()) { | ||
@@ -16,3 +16,3 @@ return writeDir(writePath, file, written); | ||
// stream it to disk yo | ||
// Stream it to disk yo | ||
if (file.isStream()) { | ||
@@ -22,3 +22,3 @@ return writeStream(writePath, file, written); | ||
// write it as a symlink | ||
// Write it as a symlink | ||
if (file.symlink) { | ||
@@ -28,3 +28,3 @@ return writeSymbolicLink(writePath, file, written); | ||
// write it like normal | ||
// Write it like normal | ||
if (file.isBuffer()) { | ||
@@ -34,3 +34,3 @@ return writeBuffer(writePath, file, written); | ||
// if no contents then do nothing | ||
// If no contents then do nothing | ||
if (file.isNull()) { | ||
@@ -72,4 +72,4 @@ return complete(); | ||
// Handle scenario for file overwrite failures. | ||
else if (err.code === 'EEXIST' && file.flag === 'wx') { | ||
if (err.code === 'EEXIST' && file.flag === 'wx') { | ||
// Handle scenario for file overwrite failures. | ||
return false; // "These aren't the droids you're looking for" | ||
@@ -76,0 +76,0 @@ } |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var utimes = require('../../utimes'); | ||
var futimes = require('../../futimes'); | ||
@@ -11,13 +11,20 @@ function writeBuffer(writePath, file, cb) { | ||
var opt = { | ||
mode: stat.mode, | ||
flag: file.flag | ||
}; | ||
fs.open(writePath, file.flag, stat.mode, function(err, fd) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
fs.writeFile(writePath, file.contents, opt, function(error) { | ||
if (error) { | ||
return cb(error); | ||
fs.write(fd, file.contents, 0, file.contents.length, 0, function(error) { | ||
if (error) { | ||
return complete(error); | ||
} | ||
futimes(fd, stat, complete); | ||
}); | ||
// Cleanup | ||
function complete(err1) { | ||
fs.close(fd, function(err2) { | ||
cb(err1 || err2); | ||
}); | ||
} | ||
utimes(writePath, stat, cb); | ||
}); | ||
@@ -24,0 +31,0 @@ } |
@@ -6,21 +6,29 @@ 'use strict'; | ||
var streamFile = require('../../src/getContents/streamFile'); | ||
var utimes = require('../../utimes'); | ||
var futimes = require('../../futimes'); | ||
function writeStream(writePath, file, cb) { | ||
var stat = file.stat; | ||
var outStream; | ||
var outFD; | ||
var opt = { | ||
mode: stat.mode, | ||
flag: file.flag | ||
}; | ||
fs.open(writePath, 'w', file.stat.mode, function(err, fd) { | ||
if (err) { | ||
cb(err); | ||
} | ||
var outStream = fs.createWriteStream(writePath, opt); | ||
outFD = fd; | ||
outStream = fs.createWriteStream(null, { fd: fd }); | ||
file.contents.once('error', complete); | ||
outStream.once('error', complete); | ||
outStream.once('finish', success); | ||
file.contents.once('error', complete); | ||
file.contents.once('end', readStreamEnd); | ||
outStream.once('error', complete); | ||
outStream.once('finish', complete); | ||
file.contents.pipe(outStream); | ||
// Streams are piped with end disabled, this prevents the | ||
// WriteStream from closing the file descriptor after all | ||
// data is written. | ||
file.contents.pipe(outStream, { end: false }); | ||
}); | ||
function success() { | ||
function readStreamEnd() { | ||
streamFile(file, {}, function(error) { | ||
@@ -31,11 +39,21 @@ if (error) { | ||
utimes(writePath, stat, complete); | ||
futimes(outFD, stat, function(error) { | ||
if (error) { | ||
return complete(error); | ||
} | ||
// All finished with WriteStream, close and clean up | ||
outStream.end(); | ||
}); | ||
}); | ||
} | ||
// cleanup | ||
// Cleanup | ||
function complete(err) { | ||
file.contents.removeListener('error', cb); | ||
outStream.removeListener('error', cb); | ||
outStream.removeListener('finish', success); | ||
file.contents.removeListener('error', complete); | ||
file.contents.removeListener('end', readStreamEnd); | ||
if (outStream) { | ||
outStream.removeListener('error', complete); | ||
outStream.removeListener('finish', complete); | ||
} | ||
cb(err); | ||
@@ -42,0 +60,0 @@ } |
@@ -6,3 +6,3 @@ 'use strict'; | ||
function writeSymbolicLink(writePath, file, cb) { | ||
fs.symlink(file.symlink, writePath, function (err) { | ||
fs.symlink(file.symlink, writePath, function(err) { | ||
if (err && err.code !== 'EEXIST') { | ||
@@ -9,0 +9,0 @@ return cb(err); |
@@ -13,5 +13,5 @@ 'use strict'; | ||
} | ||
return filter.obj(function(file){ | ||
return filter.obj(function(file) { | ||
return file.stat && file.stat.mtime > d; | ||
}); | ||
}; | ||
}; |
@@ -29,3 +29,3 @@ 'use strict'; | ||
dirMode: null, | ||
overwrite: true | ||
overwrite: true, | ||
}, opt); | ||
@@ -49,3 +49,3 @@ var overwrite = booleanOrFunc(options.overwrite, file); | ||
// wire up new properties | ||
// Wire up new properties | ||
file.stat = (file.stat || new fs.Stats()); | ||
@@ -58,4 +58,4 @@ file.stat.mode = options.mode; | ||
// mkdirp the folder the file is going in | ||
mkdirp(writeFolder, options.dirMode, function(err){ | ||
// Mkdirp the folder the file is going in | ||
mkdirp(writeFolder, options.dirMode, function(err) { | ||
if (err) { | ||
@@ -62,0 +62,0 @@ return cb(err); |
@@ -12,3 +12,3 @@ 'use strict'; | ||
if (opt.stripBOM){ | ||
if (opt.stripBOM) { | ||
file.contents = stripBom(data); | ||
@@ -15,0 +15,0 @@ } else { |
@@ -10,4 +10,4 @@ 'use strict'; | ||
function getContents(opt) { | ||
return through2.obj(function(file, enc, cb) { | ||
// don't fail to read a directory | ||
return through2.obj(opt, function(file, enc, cb) { | ||
// Don't fail to read a directory | ||
if (file.isDirectory()) { | ||
@@ -17,3 +17,3 @@ return readDir(file, opt, cb); | ||
// process symbolic links included with `followSymlinks` option | ||
// Process symbolic links included with `followSymlinks` option | ||
if (file.stat && file.stat.isSymbolicLink()) { | ||
@@ -23,3 +23,3 @@ return readSymbolicLink(file, opt, cb); | ||
// read and pass full contents | ||
// Read and pass full contents | ||
if (opt.buffer !== false) { | ||
@@ -29,3 +29,3 @@ return bufferFile(file, opt, cb); | ||
// dont buffer anything - just pass streams | ||
// Don't buffer anything - just pass streams | ||
return streamFile(file, opt, cb); | ||
@@ -32,0 +32,0 @@ }); |
'use strict'; | ||
function readDir(file, opt, cb) { | ||
// do nothing for now | ||
// Do nothing for now | ||
cb(null, file); | ||
@@ -6,0 +6,0 @@ } |
@@ -6,3 +6,3 @@ 'use strict'; | ||
function readLink(file, opt, cb) { | ||
fs.readlink(file.path, function (err, target) { | ||
fs.readlink(file.path, function(err, target) { | ||
if (err) { | ||
@@ -12,3 +12,3 @@ return cb(err); | ||
// store the link target path | ||
// Store the link target path | ||
file.symlink = target; | ||
@@ -15,0 +15,0 @@ |
@@ -5,6 +5,11 @@ 'use strict'; | ||
var stripBom = require('strip-bom-stream'); | ||
var lazystream = require('lazystream'); | ||
function streamFile(file, opt, cb) { | ||
file.contents = fs.createReadStream(file.path); | ||
var filePath = file.path; | ||
file.contents = new lazystream.Readable(function() { | ||
return fs.createReadStream(filePath); | ||
}); | ||
if (opt.stripBOM) { | ||
@@ -11,0 +16,0 @@ file.contents = file.contents.pipe(stripBom()); |
'use strict'; | ||
var assign = require('object-assign'); | ||
var through = require('through2'); | ||
var through2 = require('through2'); | ||
var gs = require('glob-stream'); | ||
@@ -27,3 +27,3 @@ var File = require('vinyl'); | ||
passthrough: false, | ||
followSymlinks: true | ||
followSymlinks: true, | ||
}, opt); | ||
@@ -41,3 +41,3 @@ | ||
.pipe(resolveSymlinks(options)) | ||
.pipe(through.obj(createFile)); | ||
.pipe(through2.obj(opt, createFile)); | ||
@@ -55,3 +55,3 @@ if (options.since != null) { | ||
if (options.passthrough === true) { | ||
inputPass = through.obj(); | ||
inputPass = through2.obj(opt); | ||
outputStream = duplexify.obj(inputPass, merge(outputStream, inputPass)); | ||
@@ -61,3 +61,3 @@ } | ||
outputStream = outputStream | ||
.pipe(sourcemaps.init({loadMaps: true})); | ||
.pipe(sourcemaps.init({ loadMaps: true })); | ||
} | ||
@@ -64,0 +64,0 @@ globStream.on('error', outputStream.emit.bind(outputStream, 'error')); |
@@ -9,5 +9,5 @@ 'use strict'; | ||
// a stat property is exposed on file objects as a (wanted) side effect | ||
// A stat property is exposed on file objects as a (wanted) side effect | ||
function resolveFile(globFile, enc, cb) { | ||
fs.lstat(globFile.path, function (err, stat) { | ||
fs.lstat(globFile.path, function(err, stat) { | ||
if (err) { | ||
@@ -23,3 +23,3 @@ return cb(err); | ||
fs.realpath(globFile.path, function (err, filePath) { | ||
fs.realpath(globFile.path, function(err, filePath) { | ||
if (err) { | ||
@@ -32,3 +32,3 @@ return cb(err); | ||
// recurse to get real file stat | ||
// Recurse to get real file stat | ||
resolveFile(globFile, enc, cb); | ||
@@ -39,5 +39,5 @@ }); | ||
return through2.obj(resolveFile); | ||
return through2.obj(options, resolveFile); | ||
} | ||
module.exports = resolveSymlinks; |
@@ -24,3 +24,3 @@ 'use strict'; | ||
var stream = through2.obj(linkFile); | ||
var stream = through2.obj(opt, linkFile); | ||
// TODO: option for either backpressure or lossy | ||
@@ -27,0 +27,0 @@ stream.resume(); |
{ | ||
"name": "vinyl-fs", | ||
"description": "Vinyl adapter for the file system", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"homepage": "http://github.com/wearefractal/vinyl-fs", | ||
@@ -15,9 +15,11 @@ "repository": "git://github.com/wearefractal/vinyl-fs.git", | ||
"duplexify": "^3.2.0", | ||
"glob-stream": "^5.0.0", | ||
"glob-stream": "^5.2.0", | ||
"graceful-fs": "^4.0.0", | ||
"gulp-sourcemaps": "^1.5.2", | ||
"is-valid-glob": "^0.3.0", | ||
"lazystream": "^1.0.0", | ||
"merge-stream": "^1.0.0", | ||
"mkdirp": "^0.5.0", | ||
"object-assign": "^4.0.0", | ||
"readable-stream": "^2.0.4", | ||
"strip-bom": "^2.0.0", | ||
@@ -31,5 +33,9 @@ "strip-bom-stream": "^1.0.0", | ||
"buffer-equal": "^0.0.1", | ||
"del": "^2.2.0", | ||
"eslint": "^1.10.3", | ||
"eslint-config-gulp": "^2.0.0", | ||
"istanbul": "^0.3.0", | ||
"istanbul-coveralls": "^1.0.1", | ||
"jshint": "^2.4.1", | ||
"jscs": "^2.4.0", | ||
"jscs-preset-gulp": "^1.0.0", | ||
"mocha": "^2.0.0", | ||
@@ -42,3 +48,4 @@ "mocha-lcov-reporter": "^1.0.0", | ||
"scripts": { | ||
"test": "jshint lib && mocha", | ||
"lint": "eslint . && jscs index.js lib/ test/", | ||
"test": "npm run lint && mocha", | ||
"coveralls": "istanbul cover _mocha && istanbul-coveralls" | ||
@@ -45,0 +52,0 @@ }, |
326
README.md
@@ -1,9 +0,21 @@ | ||
# vinyl-fs [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url] | ||
## Information | ||
<table> | ||
<tr><td>Package</td><td>vinyl-fs</td></tr> | ||
<tr><td>Description</td><td>Vinyl adapter for the file system</td></tr> | ||
<tr><td>Node Version</td><td>>= 0.10</td></tr> | ||
</table> | ||
<p align="center"> | ||
<a href="http://gulpjs.com"> | ||
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png"> | ||
</a> | ||
</p> | ||
# vinyl-fs | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] | ||
[Vinyl][vinyl] adapter for the file system. | ||
## What is Vinyl? | ||
[Vinyl][vinyl] is a very simple metadata object that describes a file. When you think of a file, two attributes come to mind: `path` and `contents`. These are the main attributes on a [Vinyl][vinyl] object. A file does not necessarily represent something on your computer’s file system. You have files on S3, FTP, Dropbox, Box, CloudThingly.io and other services. [Vinyl][vinyl] can be used to describe files from all of these sources. | ||
## What is a Vinyl Adapter? | ||
While Vinyl provides a clean way to describe a file, we now need a way to access these files. Each file source needs what I call a "Vinyl adapter". A Vinyl adapter simply exposes a `src(globs)` and a `dest(folder)` method. Each return a stream. The `src` stream produces Vinyl objects, and the `dest` stream consumes Vinyl objects. Vinyl adapters can expose extra methods that might be specific to their input/output medium, such as the `symlink` method `vinyl-fs` provides. | ||
## Usage | ||
@@ -13,3 +25,3 @@ | ||
var map = require('map-stream'); | ||
var fs = require('vinyl-fs'); | ||
var vfs = require('vinyl-fs'); | ||
@@ -21,12 +33,22 @@ var log = function(file, cb) { | ||
fs.src(['./js/**/*.js', '!./js/vendor/*.js']) | ||
vfs.src(['./js/**/*.js', '!./js/vendor/*.js']) | ||
.pipe(map(log)) | ||
.pipe(fs.dest('./output')); | ||
.pipe(vfs.dest('./output')); | ||
``` | ||
## API | ||
### src(globs[, opt]) | ||
- Takes a glob string or an array of glob strings as the first argument. | ||
- Globs are executed in order, so negations should follow positive globs. For example: | ||
### `src(globs[, options])` | ||
Takes a glob string or an array of glob strings as the first argument and an options object as the second. | ||
Returns a stream of [vinyl] `File` objects. | ||
__Note: UTF-8 BOM will be stripped from all UTF-8 files read with `.src` unless disabled in the options.__ | ||
#### Globs | ||
Globs are executed in order, so negations should follow positive globs. | ||
For example: | ||
```js | ||
@@ -36,3 +58,3 @@ fs.src(['!b*.js', '*.js']) | ||
would not exclude any files, but this would | ||
would not exclude any files, but the following would: | ||
@@ -43,79 +65,89 @@ ```js | ||
- Possible options for the second argument: | ||
- cwd - Specify the working directory the folder is relative to. | ||
- Default is `process.cwd()`. | ||
#### Options | ||
- base - Specify the folder relative to the cwd. This is used to determine the file names when saving in `.dest()`. | ||
- Default is where the glob begins if any. | ||
- Default is `process.cwd()` if there is no glob. | ||
##### `options.cwd` | ||
- buffer - `true` or `false` if you want to buffer the file. | ||
- Default value is `true`. | ||
- `false` will make `file.contents` a paused Stream. | ||
The working directory the folder is relative to. | ||
- read - `true` or `false` if you want the file to be read or not. Useful for stuff like `rm`ing files. | ||
- Default value is `true`. | ||
- `false` will disable writing the file to disk via `.dest()`. | ||
Type: `String` | ||
- since - `Date` or `number` if you only want files that have been modified since the time specified. | ||
- stripBOM - `true` or `false` if you want the BOM to be stripped on UTF-8 encoded files. | ||
- Default value is `true`. | ||
Default: `process.cwd()` | ||
- passthrough - `true` or `false` if you want a duplex stream which passes items through and emits globbed files. | ||
- Default is `false`. | ||
##### `options.base` | ||
- sourcemaps - `true` or `false` if you want files to have sourcemaps enabled. | ||
- Default is `false`. | ||
- Will load inline sourcemaps and resolve sourcemap links from files | ||
- Uses `gulp-sourcemaps` under the hood | ||
The folder relative to the cwd. This is used to determine the file names when saving in `.dest()`. | ||
- followSymlinks - `true` if you want to recursively resolve symlinks to their targets; set to `false` to preserve them as symlinks. | ||
- Default is `true`. | ||
- `false` will make `file.symlink` equal the original symlink's target path. | ||
Type: `String` | ||
- Any glob-related options are documented in [glob-stream] and [node-glob]. | ||
Default: The part of the path before the glob (if any) begins. For example, `path/to/**/*.js` would resolve to `path/to`. If there is no glob (i.e. a file path with no pattern), then the dirname of the path is used. For example, `path/to/some/file.js` would resolve to `path/to/some`. | ||
- Returns a Readable stream by default, or a Duplex stream if the `passthrough` option is set to `true`. | ||
- This stream emits matching [vinyl] File objects. | ||
##### `options.buffer` | ||
_Note:_ UTF-8 BOM will be stripped from all UTF-8 files read with `.src`. | ||
Whether or not you want to buffer the file contents into memory. Setting to `false` will make `file.contents` a paused Stream. | ||
### dest(folder[, opt]) | ||
- Takes a folder path as the first argument. | ||
- First argument can also be a function that takes in a file and returns a folder path. | ||
- Possible options for the second argument: | ||
- cwd - Specify the working directory the folder is relative to. | ||
- Default is `process.cwd()`. | ||
Type: `Boolean` | ||
- base - Specify the folder relative to the cwd. This is used to determine the file names when saving in `.dest()`. | ||
- Default is the `cwd` resolves to the folder path. | ||
- Can also be a function that takes in a file and returns a folder path. | ||
Default: `true` | ||
- mode - Specify the mode the files should be created with. | ||
- Default is the mode of the input file (file.stat.mode) if any. | ||
- Default is the process mode if the input file has no mode property. | ||
##### `options.read` | ||
- dirMode - Specify the mode the directory should be created with. | ||
- Default is the process mode. | ||
Whether or not you want the file to be read at all. Useful for stuff like removing files. Setting to `false` will make `file.contents` `null` and will disable writing the file to disk via `.dest()`. | ||
- overwrite - Specify if existing files with the same path should be overwritten or not. | ||
- Default is `true`, to always overwrite existing files. | ||
- Can also be a function that takes in a file and returns `true` or `false`. | ||
Type: `Boolean` | ||
- sourcemaps - | ||
- Default is `null` aka do not write sourcemaps. | ||
- Uses `gulp-sourcemaps` under the hood | ||
- Examples: | ||
- Write as inline comments | ||
- fs.dest('./', {sourcemaps: true}) | ||
- Write as files in the same folder | ||
- fs.dest('./', {<br> sourcemaps: {<br> path: '.'<br> }<br>}) | ||
- Any other options are passed through to `gulp-sourcemaps` | ||
- fs.dest('./', {<br> sourcemaps: {<br> path: '.',<br> addComment: false,<br> includeContent: false<br> }<br>}) | ||
Default: `true` | ||
- Returns a Readable/Writable stream. | ||
- On write the stream will save the [vinyl] File to disk at the folder/cwd specified. | ||
- After writing the file to disk, it will be emitted from the stream so you can keep piping these around. | ||
- If the file has a `symlink` attribute specifying a target path, then a symlink will be created. | ||
- The file will be modified after being written to this stream: | ||
##### `options.since` | ||
Only streams files that have been modified since the time specified. | ||
Type: `Date` or `Number` | ||
Default: `undefined` | ||
##### `options.stripBOM` | ||
Causes the BOM to be stripped on UTF-8 encoded files. Set to `false` if you need the BOM for some reason. | ||
Type: `Boolean` | ||
Default: `true` | ||
##### `options.passthrough` | ||
Allows `.src` to be used in the middle of a pipeline (using a duplex stream) which passes through all objects received and adds all files globbed to the stream. | ||
Type: `Boolean` | ||
Default: `false` | ||
##### `options.sourcemaps` | ||
Enables sourcemap support on files passed through the stream. Will load inline sourcemaps and resolve sourcemap links from files. Uses [gulp-sourcemaps] under the hood. | ||
Type: `Boolean` | ||
Default: `false` | ||
##### `options.followSymlinks` - `true` if you want | ||
Whether or not to recursively resolve symlinks to their targets. Setting to `false` to preserve them as symlinks and make `file.symlink` equal the original symlink's target path. | ||
Type: `Boolean` | ||
Default: `true` | ||
##### other | ||
Any glob-related options are documented in [glob-stream] and [node-glob]. | ||
Any through2-related options are documented in [through2]. | ||
### `dest(folder[, options])` | ||
Takes a folder path string or a function as the first argument and an options object as the second. If given a function, it will be called with each [vinyl] `File` object and must return a folder path. | ||
Returns a stream that accepts [vinyl] `File` objects, writes them to disk at the folder/cwd specified, and passes them downstream so you can keep piping these around. | ||
If the file has a `symlink` attribute specifying a target path, then a symlink will be created. | ||
__Note: The file will be modified after being written to this stream.__ | ||
- `cwd`, `base`, and `path` will be overwritten to match the folder. | ||
@@ -125,34 +157,138 @@ - `stat.mode` will be overwritten if you used a mode parameter. | ||
### symlink(folder[, opt]) | ||
- Takes a folder path as the first argument. | ||
- First argument can also be a function that takes in a file and returns a folder path. | ||
- Possible options for the second argument: | ||
- cwd - Specify the working directory the folder is relative to. | ||
- Default is `process.cwd()`. | ||
#### Options | ||
- base - Specify the folder relative to the cwd. This is used to determine the file names when saving in `.dest()`. | ||
- Default is the `cwd` resolves to the folder path. | ||
- Can also be a function that takes in a file and returns a folder path. | ||
##### `options.cwd` | ||
- dirMode - Specify the mode the directory should be created with. | ||
- Default is the process mode. | ||
The working directory the folder is relative to. | ||
- Returns a Readable/Writable stream. | ||
- On write the stream will create a symbolic link (i.e. symlink) on disk at the folder/cwd specified. | ||
- After creating the symbolic link, it will be emitted from the stream so you can keep piping these around. | ||
- The file will be modified after being written to this stream: | ||
Type: `String` | ||
Default: `process.cwd()` | ||
##### `options.base` | ||
The folder relative to the cwd. This is used to determine the file names when saving in `.dest()`. Can also be a function that takes in a file and returns a folder path. | ||
Type: `String` or `Function` | ||
Default: The `cwd` resolved to the folder path. | ||
##### `options.mode` | ||
The mode the files should be created with. | ||
Type: `Number` | ||
Default: The `mode` of the input file (`file.stat.mode`) if any, or the process mode if the input file has no `mode` property. | ||
##### `options.dirMode` | ||
The mode the directory should be created with. | ||
Type: `Number` | ||
Default: The process `mode`. | ||
##### `options.overwrite` | ||
Whether or not existing files with the same path should be overwritten. Can also be a function that takes in a file and returns `true` or `false`. | ||
Type: `Boolean` or `Function` | ||
Default: `true` (always overwrite existing files) | ||
##### `options.sourcemaps` | ||
Enables sourcemap support on files passed through the stream. Will write inline soucemaps if specified as `true`. Uses [gulp-sourcemaps] under the hood. | ||
Examples: | ||
```js | ||
// Write as inline comments | ||
vfs.dest('./', { | ||
sourcemaps: true | ||
}); | ||
// Write as files in the same folder | ||
vfs.dest('./', { | ||
sourcemaps: { | ||
path: '.' | ||
} | ||
}); | ||
// Any other options are passed through to [gulp-sourcemaps] | ||
vfs.dest('./', { | ||
sourcemaps: { | ||
path: '.', | ||
addComment: false, | ||
includeContent: false | ||
} | ||
}); | ||
``` | ||
Type: `Boolean` or `Object` | ||
Default: `undefined` (do not write sourcemaps) | ||
##### other | ||
Any through2-related options are documented in [through2]. | ||
### `symlink(folder[, options])` | ||
Takes a folder path string or a function as the first argument and an options object as the second. If given a function, it will be called with each [vinyl] `File` object and must return a folder path. | ||
Returns a stream that accepts [vinyl] `File` objects, create a symbolic link (i.e. symlink) at the folder/cwd specified, and passes them downstream so you can keep piping these around. | ||
__Note: The file will be modified after being written to this stream.__ | ||
- `cwd`, `base`, and `path` will be overwritten to match the folder. | ||
#### Options | ||
##### `options.cwd` | ||
The working directory the folder is relative to. | ||
Type: `String` | ||
Default: `process.cwd()` | ||
##### `options.base` | ||
The folder relative to the cwd. This is used to determine the file names when saving in `.symlink()`. Can also be a function that takes in a file and returns a folder path. | ||
Type: `String` or `Function` | ||
Default: The `cwd` resolved to the folder path. | ||
##### `options.dirMode` | ||
The mode the directory should be created with. | ||
Type: `Number` | ||
Default: The process mode. | ||
##### other | ||
Any through2-related options are documented in [through2]. | ||
[glob-stream]: https://github.com/gulpjs/glob-stream | ||
[gulp-sourcemaps]: https://github.com/floridoo/gulp-sourcemaps | ||
[node-glob]: https://github.com/isaacs/node-glob | ||
[gaze]: https://github.com/shama/gaze | ||
[glob-watcher]: https://github.com/gulpjs/glob-watcher | ||
[vinyl]: https://github.com/gulpjs/vinyl | ||
[glob-watcher]: https://github.com/wearefractal/glob-watcher | ||
[vinyl]: https://github.com/wearefractal/vinyl | ||
[through2]: https://github.com/rvagg/through2 | ||
[downloads-image]: http://img.shields.io/npm/dm/vinyl-fs.svg | ||
[npm-url]: https://www.npmjs.com/package/vinyl-fs | ||
[npm-image]: https://badge.fury.io/js/vinyl-fs.svg | ||
[travis-url]: https://travis-ci.org/gulpjs/vinyl-fs | ||
[travis-image]: https://travis-ci.org/gulpjs/vinyl-fs.svg?branch=master | ||
[coveralls-url]: https://coveralls.io/r/wearefractal/vinyl-fs | ||
[coveralls-image]: https://img.shields.io/coveralls/wearefractal/vinyl-fs.svg?style=flat | ||
[depstat-url]: https://david-dm.org/gulpjs/vinyl-fs | ||
[depstat-image]: https://david-dm.org/gulpjs/vinyl-fs.svg | ||
[coveralls-url]: https://coveralls.io/r/gulpjs/vinyl-fs | ||
[coveralls-image]: https://coveralls.io/repos/gulpjs/vinyl-fs/badge.svg | ||
[gitter-url]: https://gitter.im/gulpjs/gulp | ||
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.png |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25306
22
482
290
15
13
+ Addedlazystream@^1.0.0
+ Addedreadable-stream@^2.0.4
+ Addedlazystream@1.0.1(transitive)
Updatedglob-stream@^5.2.0