AbdulElahGwaith's picture
Upload folder using huggingface_hub
88df9e4 verified
import { readFileSync } from 'fs'
import matter from '@gr2m/gray-matter'
// Filters out files from a list of filePaths
// that have a type property in their frontmatter
// where the type value matches the type argument
export function checkContentType(filePaths: string[], type: string) {
const unallowedChangedFiles = []
for (const filePath of filePaths) {
const { data } = matter(readFileSync(filePath, 'utf8'))
if (data.type === type || data.contentType === type) {
unallowedChangedFiles.push(filePath)
}
}
return unallowedChangedFiles
}