From a941fe97a60b43e4249430b4e3610e2a1ecc0bc5 Mon Sep 17 00:00:00 2001 From: realies Date: Wed, 7 Mar 2018 05:40:21 +0200 Subject: [PATCH] Add install command support for package version --- src/command-line/install.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/command-line/install.js b/src/command-line/install.js index ce70bbcf..183becf2 100644 --- a/src/command-line/install.js +++ b/src/command-line/install.js @@ -23,16 +23,21 @@ program log.info("Retrieving information about the package..."); + const split = packageName.split("@"); + packageName = split[0]; + const packageVersion = split[1] || "latest"; + packageJson(packageName, { fullMetadata: true, + version: packageVersion, }).then((json) => { if (!("thelounge" in json)) { - log.error(`${colors.red(packageName)} does not have The Lounge metadata.`); + log.error(`${colors.red(json.name + " v" + json.version)} does not have The Lounge metadata.`); process.exit(1); } - log.info(`Installing ${colors.green(packageName)}...`); + log.info(`Installing ${colors.green(json.name + " v" + json.version)}...`); const packagesPath = Helper.getPackagesPath(); const packagesConfig = path.join(packagesPath, "package.json"); @@ -71,7 +76,7 @@ program "--non-interactive", "--cwd", packagesPath, - `${packageName}@${json.version}`, + `${json.name}@${json.version}`, ] ); @@ -92,11 +97,11 @@ program add.on("close", (code) => { if (!success || code !== 0) { - log.error(`Failed to install ${colors.green(packageName)}. Exit code: ${code}`); + log.error(`Failed to install ${colors.green(json.name + " v" + json.version)}. Exit code: ${code}`); return; } - log.info(`${colors.green(packageName + " v" + json.version)} has been successfully installed.`); + log.info(`${colors.green(json.name + " v" + json.version)} has been successfully installed.`); }); }).catch((e) => { log.error(`${e}`);