Skip to content

Commit

Permalink
Ensure types (specifically Buffer) are not lost across shortstop reso…
Browse files Browse the repository at this point in the history
…lves
  • Loading branch information
totherik committed Jun 19, 2014
1 parent 3e07052 commit 47b91f1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ exports.create = function create(parent) {

self = this;

if (thing.isObject(data)) {
if (thing.isObject(data) && !Buffer.isBuffer(data)) {

if (thing.isArray(data)) {
tasks = data.map(function (val) {
Expand Down
27 changes: 27 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,31 @@ test('shortstop', function (t) {
});


t.test('preserve buffers', function (t) {
var resolver;

function file(value, cb) {
require('fs').readFile(value, cb);
}

resolver = shortstop.create();
resolver.use('file', file);
resolver.resolve({ buffer: 'file:./index.js' }, function (err, data) {
t.error(err);
t.ok(data);
t.ok(data.buffer);
t.ok(Buffer.isBuffer(data.buffer));

resolver = shortstop.create();
resolver.resolve(data, function (err, data) {
t.error(err);
t.ok(data);
t.ok(data.buffer);
t.ok(Buffer.isBuffer(data.buffer));
t.end();
});
});
});


});

0 comments on commit 47b91f1

Please sign in to comment.