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