From 77038cc25ea54236c5f449a5815842e7cc44a5b9 Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Tue, 22 Oct 2024 17:07:03 -0400 Subject: [PATCH] feat(npm): add fn to Update a package's tag in the npm registry to a specific version --- src/npm/doSetNpmTag.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/npm/doSetNpmTag.ts diff --git a/src/npm/doSetNpmTag.ts b/src/npm/doSetNpmTag.ts new file mode 100644 index 00000000..c989b562 --- /dev/null +++ b/src/npm/doSetNpmTag.ts @@ -0,0 +1,20 @@ +import spawn from "../utils/spawn.js"; +import appendCmdIfWindows from "./utils/appendCmdIfWindows.js"; +import npmLogger from "./utils/npmLogger.js"; + +/** + * Update a package's tag in the npm registry to a specific version + * @param packageName The name of the package to update + * @param version The version to use for the update + * @param tag Th tag to update + * @returns + */ +export default async function ( + packageName: string, + version: string, + tag: string, +) { + const params = ["dist-tag", "add", [packageName, version].join("@"), tag]; + const npmPs = await spawn(appendCmdIfWindows`npm`, params, npmLogger); + return npmPs.stdout.toString().trim(); +}