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

Commit

Permalink
Allow pre-1.0 /v* subdirectories. (#338)
Browse files Browse the repository at this point in the history
Does not allow arbitrary minor versions, only 0.*
Matches microsoft/DefinitelyTyped-tools#723

Fixes #333
  • Loading branch information
sandersn authored Jul 30, 2021
1 parent 26d1ca2 commit 07fcc26
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
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

0 comments on commit 07fcc26

Please sign in to comment.