--
This commit is contained in:
parent
24f3d27984
commit
6b60015c02
9588 changed files with 1149251 additions and 49 deletions
23
node_modules/cardinal/lib/highlightFile.js
generated
vendored
Normal file
23
node_modules/cardinal/lib/highlightFile.js
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
var fs = require('fs')
|
||||
, highlight = require('./highlight');
|
||||
|
||||
function isFunction (obj) {
|
||||
return toString.call(obj) == '[object Function]';
|
||||
}
|
||||
|
||||
module.exports = function highlightFile (fullPath, opts, cb) {
|
||||
if (isFunction(opts)) {
|
||||
cb = opts;
|
||||
opts = { };
|
||||
}
|
||||
opts = opts || { };
|
||||
|
||||
fs.readFile(fullPath, 'utf-8', function (err, code) {
|
||||
if (err) return cb(err);
|
||||
try {
|
||||
cb(null, highlight(code, opts));
|
||||
} catch (e) {
|
||||
cb(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
Loading…
Reference in a new issue