unpkg/modules/utils/getContentType.js

24 lines
414 B
JavaScript
Raw Normal View History

2019-01-06 00:50:05 +00:00
import mime from 'mime';
2019-01-06 00:50:05 +00:00
mime.define(
{
'text/plain': [
'authors',
'changes',
'license',
'makefile',
'patents',
'readme',
'ts',
'flow'
]
},
/* force */ true
);
const textFiles = /\/?(\.[a-z]*rc|\.git[a-z]*|\.[a-z]*ignore|\.lock)$/i;
2019-01-06 00:50:05 +00:00
export default function getContentType(file) {
return textFiles.test(file) ? 'text/plain' : mime.getType(file);
}