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
This commit is contained in:
Gavin D'souza 2021-05-11 20:09:21 +05:30
parent 82685d2545
commit 548eb079c8

View file

@ -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