Skip to content

Commit 1f14938

Browse files
committedMay 28, 2018
fix: Add try/catch fallback around Buffer.from
1 parent fa09481 commit 1f14938

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎lib/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var dirname = require('path').dirname;
55
var extname = require('path').extname;
66
var marked = require('marked');
77

8+
9+
810
/**
911
* Expose `plugin`.
1012
*/
@@ -35,7 +37,13 @@ function plugin(options){
3537

3638
debug('converting file: %s', file);
3739
var str = marked(data.contents.toString(), options);
38-
data.contents = Buffer.from(str);
40+
try {
41+
// preferred
42+
data.contents = Buffer.from(str);
43+
} catch (err) {
44+
// node versions < (5.10 | 6)
45+
data.contents = new Buffer(str);
46+
}
3947
keys.forEach(function(key) {
4048
data[key] = marked(data[key], options);
4149
});

0 commit comments

Comments
 (0)
Please sign in to comment.