@@ -122,7 +122,8 @@ async function runTests(
122
122
expectOnly : boolean ,
123
123
tsLocal : string | undefined ,
124
124
) : 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 ) ) ;
126
127
127
128
const indexText = await readFile ( joinPaths ( dirPath , "index.d.ts" ) , "utf-8" ) ;
128
129
// If this *is* on DefinitelyTyped, types-publisher will fail if it can't parse the header.
@@ -219,13 +220,10 @@ async function testTypesVersion(
219
220
}
220
221
221
222
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
222
225
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 ) ) ) ) {
229
227
throw new Error ( "Since this type definition includes a header (a comment starting with `// Type definitions for`), "
230
228
+ "assumed this was a DefinitelyTyped package.\n"
231
229
+ "But it is not in a `DefinitelyTyped/types/xxx` directory: "
0 commit comments