Upgrade linguist dependency
This version changes how it counts python heredoc. All heredoc is counted as code.
This commit is contained in:
parent
a44b61d961
commit
b29bf7b05a
32 changed files with 410 additions and 339 deletions
29
node_modules/github-linguist/dist/file.js
generated
vendored
29
node_modules/github-linguist/dist/file.js
generated
vendored
|
|
@ -27,8 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LocFile = void 0;
|
||||
const fs = __importStar(require("fs-extra"));
|
||||
const Path = __importStar(require("path"));
|
||||
// @ts-ignore
|
||||
const slash2_1 = __importDefault(require("slash2"));
|
||||
const languages_1 = require("./languages");
|
||||
const DefaultLine = {
|
||||
|
|
@ -84,15 +82,16 @@ class LocFile {
|
|||
let codeLength = lines.length;
|
||||
const total = codeLength;
|
||||
let inMultiLineComment = false;
|
||||
lines.forEach((line) => {
|
||||
lines.forEach((origLine) => {
|
||||
var _a, _b, _c, _d, _e, _f;
|
||||
let lineType = 'code';
|
||||
line = line.trim();
|
||||
const line = origLine.trim();
|
||||
if (inMultiLineComment) {
|
||||
let noCode = true;
|
||||
if (regexes.multiLineCommentClose.test(line)) {
|
||||
if ((_a = regexes.multiLineCommentClose) === null || _a === void 0 ? void 0 : _a.test(line)) {
|
||||
// line contains the end of a multi-line comment
|
||||
inMultiLineComment = false;
|
||||
if (!regexes.multiLineCommentCloseEnd.test(line)) {
|
||||
if (!((_b = regexes.multiLineCommentCloseEnd) === null || _b === void 0 ? void 0 : _b.test(line))) {
|
||||
// the multiline comment does not end this line.
|
||||
// there is real code on it.
|
||||
noCode = false;
|
||||
|
|
@ -106,21 +105,21 @@ class LocFile {
|
|||
}
|
||||
else if (line) {
|
||||
// non-empty line
|
||||
if (regexes.multiLineCommentOpen.test(line)) {
|
||||
if ((_c = regexes.multiLineCommentOpen) === null || _c === void 0 ? void 0 : _c.test(line)) {
|
||||
// line contains the start of a multi-line comment
|
||||
// might contain some real code, but we'll let that slide
|
||||
if (!regexes.multiLineCommentOpenAndClose.test(line)) {
|
||||
if (!((_d = regexes.multiLineCommentOpenAndClose) === null || _d === void 0 ? void 0 : _d.test(line))) {
|
||||
// comment is not also closed on this line
|
||||
inMultiLineComment = true;
|
||||
}
|
||||
if (regexes.multiLineCommentOpenStart.test(line)) {
|
||||
if ((_e = regexes.multiLineCommentOpenStart) === null || _e === void 0 ? void 0 : _e.test(line)) {
|
||||
// The comment starts the line. There is no other code on this line
|
||||
commentLength += 1;
|
||||
codeLength -= 1;
|
||||
lineType = 'comm';
|
||||
}
|
||||
}
|
||||
else if (regexes.singleLineComment.test(line)) {
|
||||
else if ((_f = regexes.singleLineComment) === null || _f === void 0 ? void 0 : _f.test(line)) {
|
||||
// line contains only a single line comment
|
||||
commentLength += 1;
|
||||
codeLength -= 1;
|
||||
|
|
@ -155,14 +154,16 @@ class LocFile {
|
|||
throw new Error(`Error: file ${this.rawPath} does not exist.`);
|
||||
}
|
||||
let newData = data;
|
||||
const info = Object.assign({}, DefaultFileInfo);
|
||||
const name = this.path.split(Path.sep).pop() || '';
|
||||
const info = { ...DefaultFileInfo };
|
||||
// note: do not use Path.sep here since we have already
|
||||
// translated the path to a posix path using slash(...).
|
||||
const name = this.path.split('/').pop() || '';
|
||||
try {
|
||||
const stat = await fs.stat(this.path);
|
||||
if (!stat.isFile()) {
|
||||
return info;
|
||||
}
|
||||
newData = data || await fs.readFile(this.path, 'utf-8');
|
||||
newData = data || (await fs.readFile(this.path, 'utf-8'));
|
||||
info.name = name;
|
||||
info.size = (stat && stat.size) || 0;
|
||||
info.languages = this.languages.getType(this.path);
|
||||
|
|
@ -180,7 +181,7 @@ class LocFile {
|
|||
return info;
|
||||
}
|
||||
getFileInfoByContent(name, data) {
|
||||
const info = Object.assign({}, DefaultFileInfo);
|
||||
const info = { ...DefaultFileInfo };
|
||||
info.name = name;
|
||||
info.languages = this.languages.getType(name);
|
||||
info.lines = this.filterData(data, this.languages.getRegexes(info.languages));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue