From 548eb079c8b0bac8911d2cd6d2ecc0e1a7e889bb Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Tue, 11 May 2021 20:09:21 +0530 Subject: [PATCH] fix: Don't re-copy node_modules if public already has it public folder already has a symlink to node_modules. So we can just check if the realpath already exists and ignore copying it again if the same exists --- frappe/build.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frappe/build.py b/frappe/build.py index 60c8ebf79a..99f1dd3fc0 100644 --- a/frappe/build.py +++ b/frappe/build.py @@ -268,14 +268,17 @@ def generate_assets_map(): for app_name in frappe.get_all_apps(): app_doc_path = None - pymodule = frappe.get_module(app_name) app_base_path = os.path.abspath(os.path.dirname(pymodule.__file__)) + app_public_path = os.path.join(app_base_path, "public") app_node_modules_path = os.path.join(app_base_path, "..", "node_modules") + internal_app_node_modules_path = os.path.join(app_base_path, "..", "node_modules") + node_modules_required = ( + os.path.realpath(app_node_modules_path) != os.path.realpath(internal_app_node_modules_path) + ) app_docs_path = os.path.join(app_base_path, "docs") app_www_docs_path = os.path.join(app_base_path, "www", "docs") - app_assets = os.path.abspath(app_public_path) app_node_modules = os.path.abspath(app_node_modules_path) @@ -284,7 +287,8 @@ def generate_assets_map(): symlinks[app_assets] = os.path.join(assets_path, app_name) # {app}/node_modules > assets/{app}/node_modules - if os.path.isdir(app_node_modules): + # node_modules_required is set if its not already a path of {app}/public + if os.path.isdir(app_node_modules) and node_modules_required: symlinks[app_node_modules] = os.path.join(assets_path, app_name, "node_modules") # {app}/docs > assets/{app}_docs