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

Commit 07fcc26

Browse files
authored
Allow pre-1.0 /v* subdirectories. (#338)
Does not allow arbitrary minor versions, only 0.* Matches microsoft/DefinitelyTyped-tools#723 Fixes #333
1 parent 26d1ca2 commit 07fcc26

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async function runTests(
123123
expectOnly: boolean,
124124
tsLocal: string | undefined,
125125
): Promise<void> {
126-
const isOlderVersion = /^v\d+$/.test(basename(dirPath));
126+
const isOlderVersion = /^v(0\.)?\d+$/.test(basename(dirPath));
127127

128128
const indexText = await readFile(joinPaths(dirPath, "index.d.ts"), "utf-8");
129129
// If this *is* on DefinitelyTyped, types-publisher will fail if it can't parse the header.

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function isMainFile(fileName: string, allowNested: boolean) {
100100
let parent = dirname(fileName);
101101
// May be a directory for an older version, e.g. `v0`.
102102
// Note a types redirect `foo/ts3.1` should not have its own header.
103-
if (allowNested && /^v\d+$/.test(basename(parent))) {
103+
if (allowNested && /^v(0\.)?\d+$/.test(basename(parent))) {
104104
parent = dirname(parent);
105105
}
106106

test/dt-header/correct/types/foo/index.d.ts.lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for dt-header 1.0
1+
// Type definitions for dt-header 2.0
22
// Project: https://github.com/bobby-headers/dt-header
33
// Definitions by: Jane Doe <https://github.com/janedoe>
44
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Type definitions for dt-header 0.75
2+
// Project: https://github.com/bobby-headers/dt-header
3+
// Definitions by: Jane Doe <https://github.com/janedoe>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
// Minimum TypeScript Version: 3.1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Type definitions for dt-header 1.0
2+
// Project: https://github.com/bobby-headers/dt-header
3+
// Definitions by: Jane Doe <https://github.com/janedoe>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
// Minimum TypeScript Version: 3.1

0 commit comments

Comments
 (0)