Skip to content

Commit

Permalink
Allow specify dest sourcemaps option as string
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Feb 28, 2016
1 parent cd8a992 commit 7a0c94a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/dest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ function dest(outFolder, opt) {
if (typeof sourcemapOpt === 'boolean') {
sourcemapOpt = {};
}
if (typeof sourcemapOpt === 'string') {
sourcemapOpt = {
path: sourcemapOpt,
};
}

var mapStream = sourcemaps.write(sourcemapOpt.path, sourcemapOpt);
var outputStream = duplexify.obj(mapStream, saveStream);
Expand Down
26 changes: 26 additions & 0 deletions test/dest.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,32 @@ describe('dest stream', function() {
stream.end();
});

it('should not explode if the sourcemap option is string', function(done) {
var inputPath = path.join(__dirname, './fixtures/test.coffee');

var expectedFile = new File({
base: __dirname,
cwd: __dirname,
path: inputPath,
contents: null,
});

var buffered = [];

var onEnd = function() {
buffered.length.should.equal(1);
buffered[0].should.equal(expectedFile);
done();
};

var bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);

var stream = vfs.dest(path.join(__dirname, './out-fixtures/'), { sourcemaps: '.' });
stream.pipe(bufferStream);
stream.write(expectedFile);
stream.end();
});

it('should not explode if sourcemap option is an object', function(done) {
var inputPath = path.join(__dirname, './fixtures/test.coffee');

Expand Down
2 changes: 1 addition & 1 deletion test/not-owned/not-owned.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Something new
Something new

0 comments on commit 7a0c94a

Please sign in to comment.