1
0
mirror of synced 2025-12-31 06:02:42 -05:00
Files
docs/src/workflows/fm-utils.js
Rachael Sewell 117caeaa9c rai review enforcement (#47237)
Co-authored-by: Peter Bengtsson <peterbe@github.com>
2023-12-18 22:52:31 +00:00

17 lines
515 B
JavaScript

import { readFileSync } from 'fs'
import matter from '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, type) {
const unallowedChangedFiles = []
for (const filePath of filePaths) {
const { data } = matter(readFileSync(filePath, 'utf8'))
if (data.type === type) {
unallowedChangedFiles.push(filePath)
}
}
return unallowedChangedFiles
}