Add the github-linguist package
This commit only adds a single package and all of its transitive dependencies. The github-linguist package will be used for counting lines of code as a baseline for databases we are analyzing.
This commit is contained in:
parent
896b4ff181
commit
c4a84a93d4
152 changed files with 17057 additions and 24 deletions
29
node_modules/github-linguist/src/index.ts
generated
vendored
Normal file
29
node_modules/github-linguist/src/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// @ts-ignore
|
||||
import slash from 'slash2';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
import { LocDir, LocResult } from './directory';
|
||||
import { LocFile } from './file';
|
||||
|
||||
export { LocDir, LocDirOptions } from './directory';
|
||||
export { LocFile, LineInfo } from './file';
|
||||
|
||||
const loc = async (
|
||||
fileOrDir: string,
|
||||
): Promise<LocResult> => {
|
||||
const stat = await fs.stat(slash(fileOrDir));
|
||||
if (stat.isFile()) {
|
||||
const locFile = new LocFile(slash(fileOrDir));
|
||||
const info = await locFile.getFileInfo();
|
||||
const filePath = locFile.path;
|
||||
return {
|
||||
info: info.lines,
|
||||
files: [filePath],
|
||||
languages: { [info.languages]: { ...info.lines, sum: 1 } },
|
||||
};
|
||||
}
|
||||
const locDir = new LocDir({ cwd: slash(fileOrDir) });
|
||||
return locDir.loadInfo();
|
||||
};
|
||||
|
||||
export default loc;
|
||||
Loading…
Add table
Add a link
Reference in a new issue