From d2388dc623c98faa47c4f5806256837c7de9b512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Sat, 6 Jan 2018 01:34:41 -0500 Subject: [PATCH] Bail when uninstalling if package.json for TL packages does not exist It is on purpose that the message is the same than when a package was not installed. From a user standpoint, it only matters that this specific package was not installed. --- src/command-line/uninstall.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/command-line/uninstall.js b/src/command-line/uninstall.js index 1c402d77..71c63538 100644 --- a/src/command-line/uninstall.js +++ b/src/command-line/uninstall.js @@ -23,6 +23,13 @@ program const packagesPath = Helper.getPackagesPath(); const packagesParent = path.dirname(packagesPath); + const packagesConfig = path.join(packagesParent, "package.json"); + const packageWasNotInstalled = `${colors.green(packageName)} was not installed.`; + + if (!fs.existsSync(packagesConfig)) { + log.warn(packageWasNotInstalled); + return; + } const npm = child.spawn( process.platform === "win32" ? "npm.cmd" : "npm", @@ -59,7 +66,7 @@ program if (hasUninstalled) { log.info(`${colors.green(packageName)} has been successfully uninstalled.`); } else { - log.warn(`${colors.green(packageName)} was not installed.`); + log.warn(packageWasNotInstalled); } }); });