Customize a bit thelounge install|uninstall

- Hides progress bars that flash when installing/uninstalling as it does not bring real value here, at least for now
- Inform user if package being uninstalled was not actually installed
- Do not display npm outputs, mention which version was installed (this will probably need refining when installing packages with dependencies)
This commit is contained in:
Jérémie Astori 2018-01-04 22:13:46 -05:00
parent d9cb640c2a
commit 3971ecff63
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8
2 changed files with 18 additions and 4 deletions

View File

@ -55,12 +55,14 @@ program
"--no-save",
"--no-bin-links",
"--no-package-lock",
"--no-progress",
"--prefix",
packagesParent,
packageName,
],
{
stdio: "inherit",
// This is the same as `"inherit"` except `process.stdout` is ignored
stdio: [process.stdin, "ignore", process.stderr],
}
);
@ -75,7 +77,7 @@ program
return;
}
log.info(`${colors.green(packageName)} has been successfully installed.`);
log.info(`${colors.green(packageName + " v" + json.version)} has been successfully installed.`);
});
}).catch((e) => {
log.error(`${e}`);

View File

@ -28,15 +28,23 @@ program
process.platform === "win32" ? "npm.cmd" : "npm",
[
"uninstall",
"--no-progress",
"--prefix",
packagesParent,
packageName,
],
{
stdio: "inherit",
// This is the same as `"inherit"` except `process.stdout` is piped
stdio: [process.stdin, "pipe", process.stderr],
}
);
let hasUninstalled = false;
npm.stdout.on("data", () => {
hasUninstalled = true;
});
npm.on("error", (e) => {
log.error(`${e}`);
process.exit(1);
@ -48,6 +56,10 @@ program
return;
}
if (hasUninstalled) {
log.info(`${colors.green(packageName)} has been successfully uninstalled.`);
} else {
log.warn(`${colors.green(packageName)} was not installed.`);
}
});
});