From ed5a88adaee7646b4dc668d2e9b7eec919e794cf Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 5 May 2021 15:01:43 +0300 Subject: [PATCH] chore: Fix Sonar complaint --- .../server/frontend/TaskRunNpmInstall.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunNpmInstall.java b/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunNpmInstall.java index 875d5c84d59..5c43237003b 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunNpmInstall.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/frontend/TaskRunNpmInstall.java @@ -302,19 +302,24 @@ private JsonObject readGeneratedDevDependencies(String path) } private boolean shouldRunNpmInstall() { - if (packageUpdater.nodeModulesFolder.isDirectory()) { - // Ignore .bin and pnpm folders as those are always installed for - // pnpm execution - File[] installedPackages = packageUpdater.nodeModulesFolder - .listFiles( - (dir, name) -> !ignoredNodeFolders.contains(name)); - assert installedPackages != null; - return installedPackages.length == 0 - || (installedPackages.length == 1 && FLOW_NPM_PACKAGE_NAME - .startsWith(installedPackages[0].getName())) - || (installedPackages.length > 0 && isVaadinHashUpdated()); + if (!packageUpdater.nodeModulesFolder.isDirectory()) { + return true; + } + // Ignore .bin and pnpm folders as those are always installed for + // pnpm execution + File[] installedPackages = packageUpdater.nodeModulesFolder + .listFiles((dir, name) -> !ignoredNodeFolders.contains(name)); + assert installedPackages != null; + if (installedPackages.length == 0) { + // Nothing installed + return true; + } else if (installedPackages.length == 1 && FLOW_NPM_PACKAGE_NAME + .startsWith(installedPackages[0].getName())) { + // Only flow-frontend installed + return true; + } else { + return isVaadinHashUpdated(); } - return true; } private boolean isVaadinHashUpdated() {