linguist-js
Version:
Analyse the programming languages used in a folder or from raw content, using the same rules that GitHub Linguist does.
10 lines (9 loc) • 358 B
JavaScript
import { getFileExtension } from '../../program/fs/normalisedPath.js';
export function normaliseFiles(files) {
return files.map((file) => ({
...file,
extension: file.extension ?? getFileExtension(file.path),
firstLine: file.firstLine ?? file.content?.split(/\r?\n/)[0],
size: file.size ?? file.content?.length,
}));
}