Allow analysis of raw file content
Nixinova opened this issue · comments
Discussed in #9 →
Originally posted by lowlighter February 8, 2022
From what I understand, the exported analyse
function only takes a list of paths as inputs, and from there it'll walk on each file in given directories:
https://github.com/Nixinova/Linguist/blob/9a15a06266b45a0075351c8884a519d42cc252b0/src/index.ts#L16-L18
Would it be possible to expose another entry point which directly accepts a raw string as argument and returns the result instead ?
This requires a refactoring of all the index.ts
source as each stage in the analysis would need to be able to be called separately.
The function header would be something like this:
interface Metadata { filename: string, /* extension: string //? */, size: number, /* ... */ };
export default async function analyseSingle(content: string | string[], metadata: Metadata, opts?: T.Options): Promise<T.Results> {
This shouldn't need a rewrite actually, it can be done without having to move too much about
see 1878abf
Will add this change for 2.3.
@Nixinova - so, as far as I can tell, this is not yet in the codebase! Has the API changed for raw input or is there a more updated example?
See #30 (comment) 👍