[MINOR] added --make-copy-force to force copy assets
This commit is contained in:
parent
2d9e441cd0
commit
867e9997d2
3 changed files with 23 additions and 10 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"python.linting.pylintEnabled": false
|
||||
}
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue