[publisher] use consistent order for dependencies in the generated README (#531)

This commit is contained in:
Kyℓe Hensel
2022-09-02 10:08:19 +12:00
committed by GitHub
parent 5876b0824b
commit 7cc079eb00
2 changed files with 11 additions and 1 deletions

View File

@@ -243,7 +243,7 @@ export function createReadme(typing: TypingsData, packageFS: FS): string {
lines.push("");
lines.push("### Additional Details");
lines.push(` * Last updated: ${new Date().toUTCString()}`);
const dependencies = Object.keys(typing.dependencies).map(getFullNpmName);
const dependencies = Object.keys(typing.dependencies).map(getFullNpmName).sort();
lines.push(
` * Dependencies: ${
dependencies.length ? dependencies.map((d) => `[${d}](https://npmjs.com/package/${d})`).join(", ") : "none"

View File

@@ -89,6 +89,16 @@ testo({
expect.stringContaining("Dependencies: [@types/madeira](https://npmjs.com/package/@types/madeira)")
);
},
readmeMultipleDependencies() {
const typing = new TypingsData(createRawPackage(License.Apache20), /*isLatest*/ true);
// @ts-expect-error - dependencies is readonly
typing.dependencies.example = { major: 2 };
expect(createReadme(typing, defaultFS())).toEqual(
expect.stringContaining(
"Dependencies: [@types/example](https://npmjs.com/package/@types/example), [@types/madeira](https://npmjs.com/package/@types/madeira)"
)
);
},
readmeContainsSingleFileDTS() {
const typing = new TypingsData(createRawPackage(License.Apache20), /*isLatest*/ true);
expect(createReadme(typing, defaultFS())).toContain("type T = import");