Skip to content

Commit aaadcc0

Browse files
committed
feat: support pnpm for the type compatibility tests
1 parent 0ffe02d commit aaadcc0

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

test/unit/typings-compatibility-test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,33 +85,33 @@ function getItLabelDetails(tsVer: TestDef): string {
8585
}
8686

8787
describe("compatibility of typings for typescript versions", function () {
88-
let execCmd: "npm" | "yarn"
88+
let execCmd: "pnpm" | "npm" | "yarn"
8989

90-
before(function (done) {
90+
before(async function () {
9191
this.timeout(10000)
9292
if (/^true$/.test(process.env.EXCLUDE_TYPINGS_COMPAT_TESTS as string)) {
9393
this.skip()
9494
} 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.",
113111
)
114-
})
112+
}
113+
114+
execCmd = packageManagers[packageManagerIndex]
115115
}
116116
})
117117

0 commit comments

Comments
 (0)