Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Finished the mime.fileWrapper() deprecation.

  • Loading branch information...
commit 2a89be33715cca7d7621a930e54b96df9d340b39 1 parent 94185b4
@SaltwaterC authored
View
4 CHANGELOG.md
@@ -1,3 +1,7 @@
+## v0.4
+ * Deprecated the usage of mime.fileWrapper(). Calling mime() directly is preferred.
+ * jslint compliant.
+
## v0.3
* Uses different installation mode for the file(1) utility. Under restrictive environments, such as Heroku, the library may use the system installed libmagic database which is not forward compatible.
View
2  README.md
@@ -68,6 +68,8 @@ Passing relative paths is supported. The file wrapper uses child_process.execFil
## Notices
+The mime.fileWrapper method is deprecated. The preferred method is to call the module directly.
+
The module is developed under Ubuntu 12.04, and Windows 7. It is tested under OS X Lion, and FreeBSD 9.0. Other platforms may be supported, but the behavior is untested.
The Windows binaries are built by myself under Windows 7 / MinGW + MSYS. The binaries are packed with the [UPX](http://upx.sourceforge.net/) tool in order to make them smaller.
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "mime-magic",
- "version": "0.3.0",
+ "version": "0.4.0",
"main": "./lib/mime-magic.js",
"description": "Proper MIME type detection library that wraps the libmagic functionality",
"engines": {
View
28 tests/includes/test.js
@@ -1,34 +1,22 @@
-// This is the generic test for path/to/file => mime/type
+// This is the generic test for:
+// path/to/file => mime/type
+// ['path/to/file1', 'path/to/file2'] => ['mime/type1', 'mime/type2']
module.exports = function (path, expectedMime) {
'use strict';
-
+
var mime = require('../../');
var assert = require('assert');
- var callbacks = {
- mime: false,
- fileWrapper: false
- };
-
+ var callback = false;
+
mime(path, function (err, res) {
- callbacks.mime = true;
+ callback = true;
assert.ifError(err);
assert.deepEqual(res, expectedMime);
});
- mime.fileWrapper(path, function (err, res) {
- callbacks.fileWrapper = true;
- assert.ifError(err);
- assert.deepEqual(res, expectedMime);
- });
-
process.on('exit', function () {
- var i;
- for (i in callbacks) {
- if (callbacks.hasOwnProperty(i)) {
- assert.ok(callbacks[i]);
- }
- }
+ assert.ok(callback);
});
};
View
20 tests/mime-wrapper-file-not-found.js
@@ -3,28 +3,14 @@
var mime = require('../');
var assert = require('assert');
-var callbacks = {
- mime: false,
- fileWrapper: false
-};
+var callback = false;
mime('data/foobar', function (err, res) {
- callbacks.mime = true;
- assert.ok(err instanceof Error);
- assert.equal(err.code, 1);
-});
-
-mime.fileWrapper('data/foobar', function (err, res) {
- callbacks.fileWrapper = true;
+ callback = true;
assert.ok(err instanceof Error);
assert.equal(err.code, 1);
});
process.on('exit', function () {
- var i;
- for (i in callbacks) {
- if (callbacks.hasOwnProperty(i)) {
- assert.ok(callbacks[i]);
- }
- }
+ assert.ok(callback);
});
View
17 tests/mime-wrapper-text-without-extension.js
@@ -1,16 +1,3 @@
-'use strict';
+var test = require('./includes/test.js');
-var mime = require('../');
-var assert = require('assert');
-
-var callback = false;
-
-mime.fileWrapper('data/foo', function (err, res) {
- callback = true;
- assert.ifError(err);
- assert.deepEqual(res, 'text/plain');
-});
-
-process.on('exit', function () {
- assert.ok(callback);
-});
+test('data/foo', 'text/plain');
Please sign in to comment.
Something went wrong with that request. Please try again.