tsplot
Version:
A CLI and tooling library to plot Typescript project information to different template targets.
25 lines • 1.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.collectLinesOfCode = exports.collectLinesBreaks = void 0;
const tslib_1 = require("tslib");
/** @internal */
function collectLinesBreaks(str) {
return str.split('\n').filter((l) => l.trim().length).length;
}
exports.collectLinesBreaks = collectLinesBreaks;
/** @internal */
function collectLinesOfCode(files, options) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { minLinesOfCode = 1000 } = options !== null && options !== void 0 ? options : {};
return (yield Promise.all(files.map((f) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return [
f.source.fileName,
collectLinesBreaks(f.source.getText()),
];
})))).reduce((acc, [fileName, lines]) => {
return lines > minLinesOfCode ? Object.assign(Object.assign({}, acc), { [fileName]: lines }) : acc;
}, {});
});
}
exports.collectLinesOfCode = collectLinesOfCode;
//# sourceMappingURL=lines-of-code.js.map
;