Skip to content

Commit 0a4caf6

Browse files
author
Contra
committed
more elegant sourcemap handling, more docs
1 parent 0ac5a2c commit 0a4caf6

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 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]
22
## Information
3-
<table><br><tr><br><td>Package</td><td>vinyl-fs</td><br></tr><br><tr><br><td>Description</td><br><td>Vinyl adapter for the file system</td><br></tr><br><tr><br><td>Node Version</td><br><td>>= 0.10</td><br></tr><br></table>
3+
<table><br><tr><br><td>Package</td><td>vinyl-fs</td><br></tr><br><tr><br><td>Description</td><br><td>Vinyl adapter for the file system</td><br></tr><br><tr><br><td>Node Version</td><br><td>>= 0.10</td><br></tr><br></table>
44

55
## Usage
66

@@ -50,7 +50,6 @@ fs.src(['*.js', '!b*.js'])
5050
- `false` will disable writing the file to disk via `.dest()`.
5151

5252
- since - `Date` or `number` if you only want files that have been modified since the time specified.
53-
5453
- stripBOM - `true` or `false` if you want the BOM to be stripped on UTF-8 encoded files.
5554
- Default value is `true`.
5655

@@ -97,8 +96,14 @@ _Note:_ UTF-8 BOM will be stripped from all UTF-8 files read with `.src`.
9796

9897
- sourcemaps -
9998
- Default is `null` aka do not write sourcemaps.
100-
- Use `.` to write sourcemaps as files
10199
- Uses `gulp-sourcemaps` under the hood
100+
- Examples:
101+
- Write as inline comments
102+
- fs.dest('./', {sourcemaps: true})
103+
- Write as files in the same folder
104+
- fs.dest('./', {<br> sourcemaps: {<br> path: '.'<br> }<br>})
105+
- Any other options are passed through to `gulp-sourcemaps`
106+
- fs.dest('./', {<br> sourcemaps: {<br> path: '.',<br> addComment: false,<br> includeContent: false<br> }<br>})
102107

103108
- Returns a Readable/Writable stream.
104109
- On write the stream will save the [vinyl] File to disk at the folder/cwd specified.

lib/dest/index.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@
33
var through2 = require('through2');
44
var sourcemaps = require('gulp-sourcemaps');
55
var duplexify = require('duplexify');
6-
var ternaryStream = require('ternary-stream');
76
var prepareWrite = require('../prepareWrite');
87
var writeContents = require('./writeContents');
98

10-
function canSourceMap(file) {
11-
return file.isBuffer();
12-
}
13-
149
function dest(outFolder, opt) {
1510
if (!opt) {
1611
opt = {};
@@ -25,8 +20,12 @@ function dest(outFolder, opt) {
2520
});
2621
}
2722

28-
var mapStream = ternaryStream(canSourceMap, sourcemaps.write(opt.sourcemaps));
2923
var saveStream = through2.obj(saveFile);
24+
if (!opt.sourcemaps) {
25+
return saveStream;
26+
}
27+
28+
var mapStream = sourcemaps.write(opt.sourcemaps.path, opt.sourcemaps);
3029
var outputStream = duplexify.obj(mapStream, saveStream);
3130
mapStream.pipe(saveStream);
3231

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"object-assign": "^4.0.0",
2222
"strip-bom": "^2.0.0",
2323
"strip-bom-stream": "^1.0.0",
24-
"ternary-stream": "^1.2.3",
2524
"through2": "^2.0.0",
2625
"through2-filter": "^2.0.0",
2726
"vinyl": "^1.0.0"

0 commit comments

Comments
 (0)