From 7a23b8fc3e0f5f72bf5f6726e8a92241b88f9e26 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 17 Feb 2022 11:09:05 -0800 Subject: [PATCH] Account for `npm pack` bug --- packages/dts-critic/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/dts-critic/index.ts b/packages/dts-critic/index.ts index bcea4ef74f..802a6a49f4 100644 --- a/packages/dts-critic/index.ts +++ b/packages/dts-critic/index.ts @@ -315,7 +315,10 @@ function downloadNpmPackage(name: string, version: string, outDir: string): stri const fullName = `${npmName}@${version}`; const cpOpts = { encoding: "utf8", maxBuffer: 100 * 1024 * 1024 } as const; const npmPack = cp.execFileSync("npm", ["pack", fullName, "--json", "--silent"], cpOpts).trim(); - const tarballName = npmPack.endsWith(".tgz") ? npmPack : (JSON.parse(npmPack)[0].filename as string); + // https://github.com/npm/cli/issues/3405 + const tarballName = (npmPack.endsWith(".tgz") ? npmPack : (JSON.parse(npmPack)[0].filename as string)) + .replace(/^@/, '') + .replace(/\//, '-'); const outPath = path.join(outDir, name); initDir(outPath); const args =