[Pkg-javascript-commits] [node-mime-types] 07/19: update existing patch to use mime types from filesystem

Leo Iannacone l3on-guest at moszumanska.debian.org
Fri Oct 10 10:12:36 UTC 2014


This is an automated email from the git hooks/post-receive script.

l3on-guest pushed a commit to branch master
in repository node-mime-types.

commit 974a79c284f3745599219b9f2be70f97c1481edb
Author: Leo Iannacone <l3on at ubuntu.com>
Date:   Tue Oct 7 11:39:35 2014 +0200

    update existing patch to use mime types from filesystem
---
 .../0001-get_mime_types_from_filesystem.patch      |  84 -------------
 debian/patches/0001-use-system-mime-types.patch    | 134 +++++++++++++++++++++
 2 files changed, 134 insertions(+), 84 deletions(-)

diff --git a/debian/patches/0001-get_mime_types_from_filesystem.patch b/debian/patches/0001-get_mime_types_from_filesystem.patch
deleted file mode 100644
index 21ec59e..0000000
--- a/debian/patches/0001-get_mime_types_from_filesystem.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-Description: Avoid remote connections to get mime types.
- * lib/build.js: use files shipped within mime-support
-   and node-mime packages
- * Makefile:
-   - use nodejs binary
-   - provide clean task
-   - disable colors for mocha tests
- * test/mime.js: update tests according with new types
-   database
-Author: Leo Iannacone <l3on at ubuntu.com>
-Forwarded: not-needed
-
----
- Makefile     |    9 ++++++---
- build.js     |   20 ++++----------------
- test/mime.js |    2 +-
- 3 files changed, 11 insertions(+), 20 deletions(-)
-
---- a/build.js
-+++ b/build.js
-@@ -6,20 +6,12 @@
-  * Convert these text files to JSON for browser usage.
-  */
- 
--var co = require('co')
- var fs = require('fs')
- var path = require('path')
--var cogent = require('cogent')
- 
--function* get(url) {
--  var res = yield* cogent(url, {
--    string: true
--  })
--
--  if (res.statusCode !== 200)
--    throw new Error('got status code ' + res.statusCode + ' from ' + url)
-+function get(url) {
- 
--  var text = res.text
-+  var text = fs.readFileSync(url, 'utf8')
-   var json = {}
-   // http://en.wikipedia.org/wiki/Internet_media_type#Naming
-   /**
-@@ -49,9 +41,5 @@
-     JSON.stringify(json, null, 2) + '\n')
- }
- 
--co(function* () {
--  yield [
--    get('http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types'),
--    get('https://raw.githubusercontent.com/broofa/node-mime/master/types/node.types')
--  ]
--})()
-+get('/etc/mime.types')
-+get('/usr/share/node-mime/node.types')
---- a/Makefile
-+++ b/Makefile
-@@ -1,9 +1,12 @@
- 
- build:
--	node --harmony-generators build.js
-+	nodejs build.js
- 
- test:
--	node test/mime.js
--	mocha --require should --reporter spec test/test.js
-+	nodejs test/mime.js
-+	mocha -C --require should --reporter spec test/test.js
-+
-+clean:
-+	rm -f lib/mime.json lib/node.json
- 
- .PHONY: build test
---- a/test/mime.js
-+++ b/test/mime.js
-@@ -33,7 +33,7 @@
- // Test extensions
- //
- 
--eq('txt', mime.extension(mime.types.text));
-+eq('asc', mime.extension(mime.types.text));
- eq('html', mime.extension(mime.types.htm));
- eq('bin', mime.extension('application/octet-stream'));
- eq('bin', mime.extension('application/octet-stream '));
diff --git a/debian/patches/0001-use-system-mime-types.patch b/debian/patches/0001-use-system-mime-types.patch
new file mode 100644
index 0000000..68685dd
--- /dev/null
+++ b/debian/patches/0001-use-system-mime-types.patch
@@ -0,0 +1,134 @@
+Description: use system's mime-types instead of taking
+ them from Internet.
+ Update tests according with new mime types database.
+ Update README according with these changes.
+Author: Leo Iannacone <l3on at ubuntu.com>
+Forwarded: not-needed
+
+---
+ node_modules/mime-db/README.md             |    4 +--
+ node_modules/mime-db/scripts/build.js      |   31 -----------------------------
+ node_modules/mime-db/scripts/extensions.js |   20 +++---------------
+ node_modules/mime-db/test/index.js         |   13 +++---------
+ 4 files changed, 11 insertions(+), 57 deletions(-)
+
+--- a/node_modules/mime-db/scripts/build.js
++++ b/node_modules/mime-db/scripts/build.js
+@@ -1,41 +1,12 @@
+ 
+ var db = {}
+ 
+-// initialize with all the IANA types
+-require('../src/iana.json').forEach(function (mime) {
+-  // i don't think the name is useful,
+-  // and i don't think we need to bother with the "Reference"
+-  // just look at the site yourself!
+-
+-  var name = mime[0]
+-  var template = mime[1]
+-  // for some reason, references are split into multiple values...
+-  var type = mime[mime.length - 1]
+-
+-  if (!template) {
+-    // some types don't have a template, so we guess it
+-    console.log('guessing: %s/%s', type, name)
+-    template = type + '/' + name
+-  }
+-
+-  if (!~template.indexOf('/')) {
+-    // i don't know what templates exactly are,
+-    // but some aren't valid mime types.
+-    console.log('prefixing: %s/%s', type, template)
+-    template = type + '/' + template
+-  }
+-
+-  db[template.toLowerCase()] = {
+-    source: 'iana'
+-  }
+-})
+-
+ // add the mime extensions from Apache
+ var mime = require('../src/mime.json')
+ Object.keys(mime).forEach(function (type) {
+   var e = mime[type]
+   var t = type.toLowerCase()
+-  var o = db[t] = db[t] || {source: 'apache'}
++  var o = db[t] = db[t] || {source: 'mime-support'}
+   if (e.length) o.extensions = (o.extensions || []).concat(e)
+ })
+ 
+--- a/node_modules/mime-db/test/index.js
++++ b/node_modules/mime-db/test/index.js
+@@ -21,13 +21,8 @@
+     assert.equal('UTF-8', db['application/javascript'].charset)
+   })
+ 
+-  it('should set audio/x-flac with extension=flac', function () {
+-    assert.equal('flac', db['audio/x-flac'].extensions[0])
+-  })
+-
+-  it('should have guessed application/mathml+xml', function () {
+-    // because it doesn't have a "template"
+-    assert(db['application/mathml+xml'])
++  it('should set audio/flac with extension=flac', function () {
++    assert.equal('flac', db['audio/flac'].extensions[0])
+   })
+ 
+   it('should not have an empty .extensions', function () {
+@@ -39,7 +34,7 @@
+   })
+ 
+   it('should have the default .extension as the first', function () {
+-assert.equal(db['text/plain'].extensions[0], 'txt')
+-assert.equal(db['video/x-matroska'].extensions[0], 'mkv')
++assert.equal(db['text/plain'].extensions[0], 'asc')
++assert.equal(db['video/x-matroska'].extensions[0], 'mpv')
+   })
+ })
+--- a/node_modules/mime-db/README.md
++++ b/node_modules/mime-db/README.md
+@@ -11,8 +11,8 @@
+ allowing it to remain as unopinionated as possible with an API.
+ It aggregates data from the following sources:
+ 
+-- http://www.iana.org/assignments/media-types/media-types.xhtml
+-- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
++ * /etc/mime.types
++ * /usr/share/node-mime/node.types
+ 
+ ## Usage
+ 
+--- a/node_modules/mime-db/scripts/extensions.js
++++ b/node_modules/mime-db/scripts/extensions.js
+@@ -3,27 +3,15 @@
+  * Convert these text files to JSON for browser usage.
+  */
+ 
+-var co = require('co')
+ var fs = require('fs')
+ var path = require('path')
+-var cogent = require('cogent')
+ 
+-co(function* () {
+-  yield [
+-    get('http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types'),
+-    get('https://raw.githubusercontent.com/broofa/node-mime/master/types/node.types')
+-  ]
+-})()
++get('/etc/mime.types');
++get('/usr/share/node-mime/node.types');
+ 
+-function* get(url) {
+-  var res = yield* cogent(url, {
+-    string: true
+-  })
++function get(url) {
+ 
+-  if (res.statusCode !== 200)
+-    throw new Error('got status code ' + res.statusCode + ' from ' + url)
+-
+-  var text = res.text
++  var text = fs.readFileSync(url, 'utf8')
+   var json = {}
+   // http://en.wikipedia.org/wiki/Internet_media_type#Naming
+   /**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mime-types.git



More information about the Pkg-javascript-commits mailing list