Skip to content

Commit 7a0c94a

Browse files
committed
Allow specify dest sourcemaps option as string
1 parent cd8a992 commit 7a0c94a

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

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)