diff --git a/packages/dtslint/package.json b/packages/dtslint/package.json index 050049f33e..3c7ec02d2c 100644 --- a/packages/dtslint/package.json +++ b/packages/dtslint/package.json @@ -37,7 +37,8 @@ "eslint-plugin-import": "^2.29.1", "semver": "^7.5.4", "strip-json-comments": "^3.1.1", - "tar": "^6.2.0" + "tar": "^6.2.0", + "which": "^4.0.0" }, "peerDependencies": { "typescript": ">= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev || >=5.0.0-dev" @@ -47,6 +48,7 @@ "@types/semver": "^7.5.5", "@types/strip-json-comments": "^3.0.0", "@types/tar": "^6.1.9", + "@types/which": "^3.0.3", "typescript": "^5.3.3" }, "engines": { diff --git a/packages/dtslint/src/checks.ts b/packages/dtslint/src/checks.ts index 50d1df3867..25b62d5083 100644 --- a/packages/dtslint/src/checks.ts +++ b/packages/dtslint/src/checks.ts @@ -1,12 +1,13 @@ import * as header from "@definitelytyped/header-parser"; import { AllTypeScriptVersion } from "@definitelytyped/typescript-versions"; +import { deepEquals } from "@definitelytyped/utils"; import fs from "fs"; -import { join as joinPaths, dirname } from "path"; +import { dirname, join as joinPaths } from "path"; import { CompilerOptions } from "typescript"; -import { deepEquals } from "@definitelytyped/utils"; -import { readJson, packageNameFromPath } from "./util"; import { execFileSync, execSync } from "child_process"; +import which from "which"; +import { packageNameFromPath, readJson } from "./util"; export function checkPackageJson( dirPath: string, typesVersions: readonly AllTypeScriptVersion[], @@ -143,7 +144,8 @@ export function runAreTheTypesWrong(dirPath: string, implementationTarballPath: const tarballName = `types-${mangledName}-${packageJsonContent.version}.tgz`; const attwPackageJsonPath = require.resolve("@arethetypeswrong/cli/package.json"); const attwBinPath = joinPaths(dirname(attwPackageJsonPath), readJson(attwPackageJsonPath).bin.attw); - execSync("npm pack", { cwd: dirPath, stdio: "ignore", env: { ...process.env, COREPACK_ENABLE_STRICT: "0" } }); + const npmPath = which.sync("pnpm", { nothrow: true }) || which.sync("npm"); + execSync(`${npmPath} pack`, { cwd: dirPath, stdio: "ignore", env: { ...process.env, COREPACK_ENABLE_STRICT: "0" } }); try { const output = execFileSync( attwBinPath, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ebf1ddc6b5..a75cffa42d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -213,6 +213,9 @@ importers: tar: specifier: ^6.2.0 version: 6.2.0 + which: + specifier: ^4.0.0 + version: 4.0.0 devDependencies: '@types/eslint': specifier: ^8.56.2 @@ -226,6 +229,9 @@ importers: '@types/tar': specifier: ^6.1.9 version: 6.1.9 + '@types/which': + specifier: ^3.0.3 + version: 3.0.3 typescript: specifier: ^5.3.3 version: 5.3.3