Skip to content

Commit

Permalink
If the module is a single dts file, show it in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed May 20, 2021
1 parent dd16981 commit aeaf046
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/definitions-parser/src/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ export class TypingsData extends PackageBase {
get files(): readonly string[] {
return this.data.files;
}
get dtsFiles(): readonly string[] {
return this.data.files.filter(f => f.endsWith(".d.ts"));
}
get license(): License {
return this.data.license;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/publisher/src/generate-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ export function createReadme(typing: TypingsData): string {
lines.push("# Details");
lines.push(`Files were exported from ${definitelyTypedURL}/tree/${sourceBranch}/types/${typing.subDirectoryPath}.`);

if (typing.dtsFiles.length === 1) {
const dts = typing.dtsFiles[0]
lines.push("## " + path.basename(dts))
lines.push("```ts")
lines.push(readFileSync(dts, "utf8"))
lines.push("```")
}

lines.push("");
lines.push("### Additional Details");
lines.push(` * Last updated: ${new Date().toUTCString()}`);
Expand Down

0 comments on commit aeaf046

Please sign in to comment.