Skip to content

Commit 4c0288f

Browse files
author
contra
committed
Merge pull request #160 from TrySound/sourcemaps-string
Allow specify dest sourcemaps option as string
2 parents cd8a992 + ebaffbe commit 4c0288f

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ Default: `true` (always overwrite existing files)
199199

200200
##### `options.sourcemaps`
201201

202-
Enables sourcemap support on files passed through the stream. Will write inline soucemaps if specified as `true`. Uses [gulp-sourcemaps] under the hood.
202+
Enables sourcemap support on files passed through the stream. Will write inline soucemaps if specified as `true`.
203+
Specifying a `string` is shorthand for the path option. Uses [gulp-sourcemaps] under the hood.
203204

204205
Examples:
205206

@@ -211,9 +212,7 @@ vfs.dest('./', {
211212

212213
// Write as files in the same folder
213214
vfs.dest('./', {
214-
sourcemaps: {
215-
path: '.'
216-
}
215+
sourcemaps: '.'
217216
});
218217

219218
// Any other options are passed through to [gulp-sourcemaps]
@@ -226,7 +225,7 @@ vfs.dest('./', {
226225
});
227226
```
228227

229-
Type: `Boolean` or `Object`
228+
Type: `Boolean`, `String` or `Object`
230229

231230
Default: `undefined` (do not write sourcemaps)
232231

lib/dest/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ function dest(outFolder, opt) {
3434
if (typeof sourcemapOpt === 'boolean') {
3535
sourcemapOpt = {};
3636
}
37+
if (typeof sourcemapOpt === 'string') {
38+
sourcemapOpt = {
39+
path: sourcemapOpt,
40+
};
41+
}
3742

3843
var mapStream = sourcemaps.write(sourcemapOpt.path, sourcemapOpt);
3944
var outputStream = duplexify.obj(mapStream, saveStream);

test/dest.js

+26
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,32 @@ describe('dest stream', function() {
103103
stream.end();
104104
});
105105

106+
it('should not explode if the sourcemap option is string', function(done) {
107+
var inputPath = path.join(__dirname, './fixtures/test.coffee');
108+
109+
var expectedFile = new File({
110+
base: __dirname,
111+
cwd: __dirname,
112+
path: inputPath,
113+
contents: null,
114+
});
115+
116+
var buffered = [];
117+
118+
var onEnd = function() {
119+
buffered.length.should.equal(1);
120+
buffered[0].should.equal(expectedFile);
121+
done();
122+
};
123+
124+
var bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);
125+
126+
var stream = vfs.dest(path.join(__dirname, './out-fixtures/'), { sourcemaps: '.' });
127+
stream.pipe(bufferStream);
128+
stream.write(expectedFile);
129+
stream.end();
130+
});
131+
106132
it('should not explode if sourcemap option is an object', function(done) {
107133
var inputPath = path.join(__dirname, './fixtures/test.coffee');
108134

test/not-owned/not-owned.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Something new
1+
Something new

0 commit comments

Comments
 (0)