Last active
October 6, 2015 23:20
-
-
Save grantmacken/2659def7a17452172d85 to your computer and use it in GitHub Desktop.
Make function get mime-type using #existdb mime-types file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# makes a shell call to node and uses cheerio to extract mimetype from | |
# passed in file name | |
# depends on cheerio node_module in reachable node path | |
getMimeType = $(shell node -pe "\ | |
fs = require('fs');\ | |
re = /$1/;\ | |
n = require('cheerio').load(fs.readFileSync('$(EXIST_HOME)/mime-types.xml'),\ | |
{ normalizeWhitespace: true, xmlMode: true});\ | |
n('extensions').filter(function(i, el){\ | |
return re.test(n(this).text());\ | |
}).parent().attr('name');\ | |
") | |
# Used in make target like below | |
# @echo $(call getMimeType,$(suffix $(notdir $<))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment