Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support arrays of paths, with the callback getting an array of mime-t…

…ypes.
  • Loading branch information...
commit 0a7caccc42cda09d7a9324eb149d9bf197a615c6 1 parent 7a28a0c
eddyb authored
Showing with 4 additions and 8 deletions.
  1. +4 −8 lib/mime-magic.js
View
12 lib/mime-magic.js
@@ -5,18 +5,14 @@ var fileExec = p.resolve(__dirname + '/../bin/file');
var fileFlags = ['--magic-file', p.resolve(__dirname + '/../share/magic.mgc'), '--brief', '--mime-type'];
var fileWrapper = function (path, cb) {
- var flags = JSON.parse(JSON.stringify(fileFlags));
- flags.push(path);
- cp.execFile(fileExec, flags, function (err, stdout) {
+ cp.execFile(fileExec, fileFlags.concat(Array.isArray(path) ? path : [path]), function (err, stdout) {
stdout = stdout.trim();
if (err) {
- if (stdout) {
+ if (stdout)
err.message = stdout;
- }
cb(err);
- } else {
- cb(null, stdout);
- }
+ } else
+ cb(null, Array.isArray(path) ? stdout.split('\n') : stdout);
});
};
exports.fileWrapper = fileWrapper;
Please sign in to comment.
Something went wrong with that request. Please try again.