2018-12-17 17:38:05 +00:00
|
|
|
const mime = require('mime');
|
2018-07-04 23:30:11 +00:00
|
|
|
|
|
|
|
mime.define({
|
2018-12-17 17:38:05 +00:00
|
|
|
'text/plain': [
|
|
|
|
'authors',
|
|
|
|
'changes',
|
|
|
|
'license',
|
|
|
|
'makefile',
|
|
|
|
'patents',
|
|
|
|
'readme',
|
|
|
|
'ts',
|
|
|
|
'flow'
|
2018-07-04 23:30:11 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
const textFiles = /\/?(\.[a-z]*rc|\.git[a-z]*|\.[a-z]*ignore|\.lock)$/i;
|
|
|
|
|
|
|
|
function getContentType(file) {
|
2018-12-17 17:38:05 +00:00
|
|
|
return textFiles.test(file) ? 'text/plain' : mime.lookup(file);
|
2018-07-04 23:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = getContentType;
|