Skip to content

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 #723

Fixes #333
  • Loading branch information
sandersn committed Nov 29, 2021
1 parent 0ec1e3b commit 7567886
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/dtslint/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 packages/dtslint/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
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
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
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 7567886

Please sign in to comment.