@@ -85,33 +85,33 @@ function getItLabelDetails(tsVer: TestDef): string {
85
85
}
86
86
87
87
describe ( "compatibility of typings for typescript versions" , function ( ) {
88
- let execCmd : "npm" | "yarn"
88
+ let execCmd : "pnpm" | " npm" | "yarn"
89
89
90
- before ( function ( done ) {
90
+ before ( async function ( ) {
91
91
this . timeout ( 10000 )
92
92
if ( / ^ t r u e $ / . test ( process . env . EXCLUDE_TYPINGS_COMPAT_TESTS as string ) ) {
93
93
this . skip ( )
94
94
} else {
95
- // detect package manager (npm or yarn) for installing typescript versions
96
- Promise . all ( [
97
- run ( "npm --version" , tscTestBasePath , false ) ,
98
- run ( "yarn --version" , tscTestBasePath , false ) ,
99
- ] ) . then ( results => {
100
- if ( results . length === 2 ) {
101
- if ( ! results [ 0 ] ) {
102
- execCmd = "npm"
103
- } else if ( ! results [ 1 ] ) {
104
- execCmd = "yarn"
105
- }
106
- if ( execCmd ) {
107
- return done ( )
108
- }
109
- }
110
- done (
111
- "Cannot run typings compatibility test," +
112
- " because neither npm nor yarn are available." ,
95
+ // detect package manager (pnpm, npm, yarn) for installing typescript versions
96
+ const packageManagers = [ "pnpm" , "yarn" , "npm" ] as typeof execCmd [ ]
97
+
98
+ const versionResults = await Promise . all (
99
+ packageManagers . map ( pm =>
100
+ run ( `${ pm } --version` , tscTestBasePath , false ) ,
101
+ ) ,
102
+ )
103
+
104
+ const packageManagerIndex = versionResults . findIndex (
105
+ versionResult => typeof versionResult === "string" ,
106
+ )
107
+
108
+ if ( packageManagerIndex === - 1 ) {
109
+ throw new Error (
110
+ "Cannot run typings compatibility test, because pnpm, npm, and yarn are not available." ,
113
111
)
114
- } )
112
+ }
113
+
114
+ execCmd = packageManagers [ packageManagerIndex ]
115
115
}
116
116
} )
117
117
0 commit comments