Serve .flow files as text/plain
This commit is contained in:
parent
e4f5bfe4c0
commit
db53a296aa
|
@ -8,17 +8,19 @@ mime.define({
|
|||
'changes',
|
||||
'authors',
|
||||
'makefile',
|
||||
'ts'
|
||||
'ts',
|
||||
'flow'
|
||||
]
|
||||
})
|
||||
|
||||
const TextFiles = /\/?(\.[a-z]*rc|\.git[a-z]*|\.[a-z]*ignore)$/i
|
||||
|
||||
const getContentType = (file) =>
|
||||
TextFiles.test(file) ? 'text/plain' : mime.lookup(file)
|
||||
function getContentType(file) {
|
||||
return TextFiles.test(file) ? 'text/plain' : mime.lookup(file)
|
||||
}
|
||||
|
||||
const getStats = (file) =>
|
||||
new Promise((resolve, reject) => {
|
||||
function getStats(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.lstat(file, (error, stats) => {
|
||||
if (error) {
|
||||
reject(error)
|
||||
|
@ -27,8 +29,9 @@ const getStats = (file) =>
|
|||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const getFileType = (stats) => {
|
||||
function getFileType(stats) {
|
||||
if (stats.isFile()) return 'file'
|
||||
if (stats.isDirectory()) return 'directory'
|
||||
if (stats.isBlockDevice()) return 'blockDevice'
|
||||
|
|
|
@ -28,3 +28,7 @@ it('gets a content type of text/plain for .ts files', () => {
|
|||
expect(getContentType('app.ts')).toBe('text/plain')
|
||||
expect(getContentType('app.d.ts')).toBe('text/plain')
|
||||
})
|
||||
|
||||
it('gets a content type of text/plain for .flow files', () => {
|
||||
expect(getContentType('app.js.flow')).toBe('text/plain')
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue