From 8e1205e6d36e0c365f8d4c5d1285c90f02b41ae8 Mon Sep 17 00:00:00 2001 From: Svetoslav Tsenov Date: Mon, 17 Sep 2018 13:56:59 +0300 Subject: [PATCH] chore(prepublish): change script name; accepts --distTag option --- build/{prepublish-next.js => prepublish.js} | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) rename build/{prepublish-next.js => prepublish.js} (62%) diff --git a/build/prepublish-next.js b/build/prepublish.js similarity index 62% rename from build/prepublish-next.js rename to build/prepublish.js index a4ce1229..41b76817 100644 --- a/build/prepublish-next.js +++ b/build/prepublish.js @@ -3,10 +3,18 @@ const { dirname: pathDirname } = require("path"); const { getPackageJson, writePackageJson } = require("../projectHelpers"); -const tag = "next"; +let processArgs = process.argv; +const distTag = processArgs.includes("--distTag") ? processArgs[processArgs.indexOf("--distTag") + 1] : undefined; + +const tag = distTag || process.env["distTag"] || "next"; + const projectDir = pathDirname(__dirname); const packageJson = getPackageJson(projectDir); -const [, , packageVersion = new Date() ] = process.argv; + +if (distTag) { + processArgs = processArgs.splice(processArgs.indexOf("--distTag"), 2); +} +const [, , packageVersion = new Date()] = processArgs; packageJson.publishConfig = Object.assign( packageJson.publishConfig || {},