save, but will need polish of nodejs integration when there are errors

This commit is contained in:
Martin Rotter 2022-02-15 12:47:52 +01:00
parent 25ae21c8e8
commit fd7b407de4
4 changed files with 20 additions and 13 deletions

View file

@ -848,7 +848,7 @@ void Application::parseCmdArgumentsFromMyInstance() {
} }
void Application::onNodeJsPackageUpdateError(const QList<NodeJs::PackageMetadata>& pkgs, const QString& error) { void Application::onNodeJsPackageUpdateError(const QList<NodeJs::PackageMetadata>& pkgs, const QString& error) {
qApp->showGuiMessage(Notification::Event::NodePackageUpdated, qApp->showGuiMessage(Notification::Event::NodePackageFailedToUpdate,
{ {}, { {},
tr("Packages %1 were NOT updated because of error: %3.").arg(NodeJs::packagesToString(pkgs), tr("Packages %1 were NOT updated because of error: %3.").arg(NodeJs::packagesToString(pkgs),
error), error),

View file

@ -99,6 +99,7 @@ void NodeJs::installUpdatePackages(const QList<PackageMetadata>& pkgs) {
QStringList desc; QStringList desc;
for (const PackageMetadata& mt : pkgs) { for (const PackageMetadata& mt : pkgs) {
try {
auto pkg_status = packageStatus(mt); auto pkg_status = packageStatus(mt);
switch (pkg_status) { switch (pkg_status) {
@ -112,6 +113,12 @@ void NodeJs::installUpdatePackages(const QList<PackageMetadata>& pkgs) {
break; break;
} }
} }
catch (const ApplicationException& ex) {
emit packageError(pkgs, ex.message());
return;
}
}
if (to_install.isEmpty()) { if (to_install.isEmpty()) {
qDebugNN << LOGSEC_NODEJS << "Packages" << QUOTE_W_SPACE(desc.join(QL1S(", "))) << "are up-to-date."; qDebugNN << LOGSEC_NODEJS << "Packages" << QUOTE_W_SPACE(desc.join(QL1S(", "))) << "are up-to-date.";

View file

@ -64,6 +64,8 @@ class NodeJs : public QObject {
// NOTE: https://docs.npmjs.com/cli/v8/commands/npm-install // NOTE: https://docs.npmjs.com/cli/v8/commands/npm-install
void installUpdatePackages(const QList<PackageMetadata>& pkgs); void installUpdatePackages(const QList<PackageMetadata>& pkgs);
void installPackages(const QList<PackageMetadata>& pkgs);
static QString packagesToString(const QList<PackageMetadata>& pkgs); static QString packagesToString(const QList<PackageMetadata>& pkgs);
signals: signals:
@ -71,8 +73,6 @@ class NodeJs : public QObject {
void packageInstalledUpdated(const QList<PackageMetadata>& pkgs, bool already_up_to_date); void packageInstalledUpdated(const QList<PackageMetadata>& pkgs, bool already_up_to_date);
private: private:
void installPackages(const QList<PackageMetadata>& pkgs);
Settings* m_settings; Settings* m_settings;
}; };

View file

@ -74,7 +74,7 @@ void Readability::makeHtmlReadable(const QString& html, const QString& base_url)
"You will be notified when installation is complete.").arg(QSL(APP_NAME)), "You will be notified when installation is complete.").arg(QSL(APP_NAME)),
QSystemTrayIcon::MessageIcon::Information }, QSystemTrayIcon::MessageIcon::Information },
{ true, true, false }); { true, true, false });
qApp->nodejs()->installUpdatePackages({ { QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION) } }); qApp->nodejs()->installPackages({ { QSL(READABILITY_PACKAGE), QSL(READABILITY_VERSION) } });
} }
return; return;