From 14d24a083f9d25221b5e2797e5133631f4d966ca Mon Sep 17 00:00:00 2001 From: Jon Uhlmann Date: Tue, 17 Oct 2023 20:04:30 +0200 Subject: [PATCH] Update: Remove config key if set --- setPackageManager.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setPackageManager.js b/setPackageManager.js index 12c52ac..576648d 100644 --- a/setPackageManager.js +++ b/setPackageManager.js @@ -1,9 +1,18 @@ -const { scripts } = require("../../package.json"); +const { scripts, config } = require("../../package.json"); const { execSync } = require("child_process"); const newPackageManager = process.argv[2]; const packageManagers = ["pnpm", "npm", "yarn"]; +if (config?.packageManager) { + const isAlone = Object.keys(config).length == 1; + if (isAlone) { + execSync("npm pkg delete config"); + } else { + execSync("npm pkg delete config.packageManager"); + } +} + if (!newPackageManager) { errorMessage("Please specify a package manager as an argument."); }