diff --git a/src/index.ts b/src/index.ts index 2f96b616..2b57b51e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -123,7 +123,7 @@ async function runTests( expectOnly: boolean, tsLocal: string | undefined, ): Promise { - 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. diff --git a/src/util.ts b/src/util.ts index 5c99dc40..1a0e9791 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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); } diff --git a/test/dt-header/correct/types/foo/index.d.ts.lint b/test/dt-header/correct/types/foo/index.d.ts.lint index 96bd3849..300eb907 100644 --- a/test/dt-header/correct/types/foo/index.d.ts.lint +++ b/test/dt-header/correct/types/foo/index.d.ts.lint @@ -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 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/test/dt-header/correct/types/foo/v0.75/index.d.ts.lint b/test/dt-header/correct/types/foo/v0.75/index.d.ts.lint new file mode 100644 index 00000000..71915f71 --- /dev/null +++ b/test/dt-header/correct/types/foo/v0.75/index.d.ts.lint @@ -0,0 +1,5 @@ +// Type definitions for dt-header 0.75 +// Project: https://github.com/bobby-headers/dt-header +// Definitions by: Jane Doe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Minimum TypeScript Version: 3.1 diff --git a/test/dt-header/correct/types/foo/v1/index.d.ts.lint b/test/dt-header/correct/types/foo/v1/index.d.ts.lint new file mode 100644 index 00000000..96bd3849 --- /dev/null +++ b/test/dt-header/correct/types/foo/v1/index.d.ts.lint @@ -0,0 +1,5 @@ +// Type definitions for dt-header 1.0 +// Project: https://github.com/bobby-headers/dt-header +// Definitions by: Jane Doe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Minimum TypeScript Version: 3.1