Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Allow pre-1.0 /v* subdirectories. #338

Merged
merged 1 commit into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function runTests(
expectOnly: boolean,
tsLocal: string | undefined,
): Promise<void> {
const isOlderVersion = /^v\d+$/.test(basename(dirPath));
const isOlderVersion = /^v(0\.)?\d+$/.test(basename(dirPath));

const indexText = await readFile(joinPaths(dirPath, "index.d.ts"), "utf-8");
// If this *is* on DefinitelyTyped, types-publisher will fail if it can't parse the header.
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function isMainFile(fileName: string, allowNested: boolean) {
let parent = dirname(fileName);
// May be a directory for an older version, e.g. `v0`.
// Note a types redirect `foo/ts3.1` should not have its own header.
if (allowNested && /^v\d+$/.test(basename(parent))) {
if (allowNested && /^v(0\.)?\d+$/.test(basename(parent))) {
parent = dirname(parent);
}

Expand Down
2 changes: 1 addition & 1 deletion test/dt-header/correct/types/foo/index.d.ts.lint
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for dt-header 1.0
// Type definitions for dt-header 2.0
// Project: https://github.com/bobby-headers/dt-header
// Definitions by: Jane Doe <https://github.com/janedoe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand Down
5 changes: 5 additions & 0 deletions test/dt-header/correct/types/foo/v0.75/index.d.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Type definitions for dt-header 0.75
// Project: https://github.com/bobby-headers/dt-header
// Definitions by: Jane Doe <https://github.com/janedoe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.1
5 changes: 5 additions & 0 deletions test/dt-header/correct/types/foo/v1/index.d.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Type definitions for dt-header 1.0
// Project: https://github.com/bobby-headers/dt-header
// Definitions by: Jane Doe <https://github.com/janedoe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.1