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

Commit 8348ba3

Browse files
committed
When package names match the older-version pattern
1 parent 9c555b9 commit 8348ba3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/index.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ async function runTests(
122122
expectOnly: boolean,
123123
tsLocal: string | undefined,
124124
): Promise<void> {
125-
const isOlderVersion = /^v\d+$/.test(basename(dirPath));
125+
const parent = dirname(dirPath);
126+
const isOlderVersion = basename(parent) !== "types" && /^v\d+(\.\d+)?$/.test(basename(dirPath));
126127

127128
const indexText = await readFile(joinPaths(dirPath, "index.d.ts"), "utf-8");
128129
// If this *is* on DefinitelyTyped, types-publisher will fail if it can't parse the header.
@@ -219,13 +220,10 @@ async function testTypesVersion(
219220
}
220221

221222
function assertPathIsInDefinitelyTyped(dirPath: string): void {
223+
// A DefinitelyTyped package must be a child of a "types" directory,
224+
// or be an older version and a grandchild of a "types" directory
222225
const parent = dirname(dirPath);
223-
const types = /^v\d+(\.\d+)?$/.test(basename(dirPath)) ? dirname(parent) : parent;
224-
// TODO: It's not clear whether this assertion makes sense, and it's broken on Azure Pipelines
225-
// Re-enable it later if it makes sense.
226-
// const dt = dirname(types);
227-
// if (basename(dt) !== "DefinitelyTyped" || basename(types) !== "types") {
228-
if (basename(types) !== "types") {
226+
if (basename(parent) !== "types" && (basename(dirname(parent)) !== "types" || !/^v\d+(\.\d+)?$/.test(basename(dirPath)))) {
229227
throw new Error("Since this type definition includes a header (a comment starting with `// Type definitions for`), "
230228
+ "assumed this was a DefinitelyTyped package.\n"
231229
+ "But it is not in a `DefinitelyTyped/types/xxx` directory: "

0 commit comments

Comments
 (0)