Skip to content

Commit

Permalink
Allow transform of Transformers to return promise (#119)
Browse files Browse the repository at this point in the history
It allow Transformer#transform to work as async.
  • Loading branch information
azu authored and fkling committed May 9, 2016
1 parent 6f9ff8c commit da3cf77
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/TransformOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ function transform(transformer, transformCode, code) {
transformCode,
code,
);
let map = null;
if (typeof result !== 'string') {
map = new SourceMapConsumer(result.map);
result = result.code;
}
return { result, map };
return Promise.resolve(result).then(result => {
let map = null;
if (typeof result !== 'string') {
map = new SourceMapConsumer(result.map);
result = result.code;
}
return { result, map };
});
});
}

Expand Down

0 comments on commit da3cf77

Please sign in to comment.