Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Work around npm pack issue with scoped packages #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,13 @@ 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;
let tarballName = npmPack.endsWith(".tgz") ? npmPack : JSON.parse(npmPack)[0].filename as string;

// Npm does not report the correct filename for scoped packages. See https://github.com/npm/cli/issues/3405.
if (!fs.existsSync(tarballName)) {
tarballName = tarballName.replace(/^@/, '').replace(/\//, '-');
}

const outPath = path.join(outDir, name);
initDir(outPath);
const args = os.platform() === "darwin"
Expand Down