linguist-js
Version:
Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.
13 lines (12 loc) • 439 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = parseGitignore;
function parseGitignore(content) {
const readableData = content
// Remove comments unless escaped
.replace(/(?<!\\)#.+/g, '')
// Remove whitespace unless escaped
.replace(/(?:(?<!\\)\s)+$/g, '');
const arrayData = readableData.split(/\r?\n/).filter(data => data);
return arrayData;
}