diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..fe7159848b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.linting.pylintEnabled": false +} \ No newline at end of file diff --git a/frappe/build.py b/frappe/build.py index 2a201fee6f..77f42fc59d 100644 --- a/frappe/build.py +++ b/frappe/build.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals, print_function from frappe.utils.minify import JavascriptMinify import subprocess +import warnings from six import iteritems, text_type @@ -25,12 +26,12 @@ def setup(): except ImportError: pass app_paths = [os.path.dirname(pymodule.__file__) for pymodule in pymodules] -def bundle(no_compress, make_copy=False, verbose=False): +def bundle(no_compress, make_copy=False, make_copy_force=False, verbose=False): """concat / minify js files""" # build js files setup() - make_asset_dirs(make_copy=make_copy) + make_asset_dirs(make_copy=make_copy, make_copy_force = make_copy_force) # new nodejs build system command = 'node --use_strict ../apps/frappe/frappe/build.js --build' @@ -60,7 +61,7 @@ def watch(no_compress): # time.sleep(3) -def make_asset_dirs(make_copy=False): +def make_asset_dirs(make_copy=False, make_copy_force=False): assets_path = os.path.join(frappe.local.sites_path, "assets") for dir_path in [ os.path.join(assets_path, 'js'), @@ -80,11 +81,19 @@ def make_asset_dirs(make_copy=False): for source, target in symlinks: source = os.path.abspath(source) - if not os.path.exists(target) and os.path.exists(source): - if make_copy: - shutil.copytree(source, target) - else: - os.symlink(source, target) + if os.path.exists(source): + if os.path.exists(target): + if make_copy_force: + if not make_copy: + os.unlink(target) + shutil.copytree(source, target) + else: + warnings.warn('Target {target} already exists.'.format(target = target)) + pass # if exists, don't make copy. + else: + os.symlink(source, target) + else: + warnings.warn('Source {source} does not exists.'.format(source = source)) def build(no_compress=False, verbose=False): assets_path = os.path.join(frappe.local.sites_path, "assets") diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 7c18bdbc78..9fa1ff3dbe 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -7,13 +7,14 @@ from frappe.commands import pass_context, get_site @click.command('build') @click.option('--make-copy', is_flag=True, default=False, help='Copy the files instead of symlinking') +@click.option('--make-copy-force', is_flag=True, default=False, help='Copy the files instead of symlinking with force') @click.option('--verbose', is_flag=True, default=False, help='Verbose') -def build(make_copy=False, verbose=False): +def build(make_copy=False, make_copy_force = False, verbose=False): "Minify + concatenate JS and CSS files, build translations" import frappe.build import frappe frappe.init('') - frappe.build.bundle(False, make_copy=make_copy, verbose=verbose) + frappe.build.bundle(False, make_copy=make_copy, make_copy_force = make_copy_force, verbose=verbose) @click.command('watch') def watch():