Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support arrays of paths, with the callback getting an array of mime-types. #3

Closed
wants to merge 1 commit into from

2 participants

@eddyb

Also got rid of the JSON duplicating trick.

@SaltwaterC
Owner

Thanks. I'll merge it ASAP.

@SaltwaterC SaltwaterC referenced this pull request from a commit
@SaltwaterC Merging the changes from #3. 1e5d51e
@SaltwaterC SaltwaterC referenced this pull request from a commit
@SaltwaterC Added an unit test for #3. 89f2365
@SaltwaterC
Owner

Your changes are completely integrated into the future branch. I'll publish the new version as soon as I'll make a new build for the Windows binaries since file 5.11 is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 24, 2012
This page is out of date. Refresh to see the latest.
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;
Something went wrong with that request. Please try again.