From d950904eac41631d43eb2ae81c1a6564243efefd Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 13 Mar 2014 02:13:23 +0530 Subject: [PATCH] add option to copy files while asset building --- frappe/build.py | 11 +++++++---- frappe/cli.py | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frappe/build.py b/frappe/build.py index 79ac453547..3f49530dfa 100644 --- a/frappe/build.py +++ b/frappe/build.py @@ -11,10 +11,10 @@ Build the `public` folders and setup languages import os, sys, frappe, json, shutil from cssmin import cssmin -def bundle(no_compress): +def bundle(no_compress, make_copy=False): """concat / minify js files""" # build js files - make_asset_dirs() + make_asset_dirs(make_copy=make_copy) build(no_compress) def watch(no_compress): @@ -28,7 +28,7 @@ def watch(no_compress): time.sleep(3) -def make_asset_dirs(): +def make_asset_dirs(make_copy=False): assets_path = os.path.join(frappe.local.sites_path, "assets") for dir_path in [ os.path.join(assets_path, 'js'), @@ -44,7 +44,10 @@ def make_asset_dirs(): target = os.path.join(assets_path, app_name) if not os.path.exists(target) and os.path.exists(source): - os.symlink(os.path.abspath(source), target) + if make_copy: + shutil.copytree(os.path.abspath(source), target) + else: + os.symlink(os.path.abspath(source), target) def build(no_compress=False): assets_path = os.path.join(frappe.local.sites_path, "assets") diff --git a/frappe/cli.py b/frappe/cli.py index 787c98edfe..5e383d2cce 100755 --- a/frappe/cli.py +++ b/frappe/cli.py @@ -156,6 +156,8 @@ def setup_utilities(parser): # build parser.add_argument("-b", "--build", default=False, action="store_true", help="Minify + concatenate JS and CSS files, build translations") + parser.add_argument("--make_copy", default=False, action="store_true", + help="Make copy of assets instead of symlinks") parser.add_argument("-w", "--watch", default=False, action="store_true", help="Watch and concatenate JS and CSS files as and when they change") @@ -379,10 +381,10 @@ def reload_doc(module, doctype, docname, force=False): frappe.destroy() @cmd -def build(): +def build(make_copy=False): import frappe.build import frappe - frappe.build.bundle(False) + frappe.build.bundle(False, make_copy=make_copy) @cmd def watch():