Ver código fonte

revert to npm if yarn doesnt exist (#5058)

version-14
Achilles Rasquinha 7 anos atrás
committed by Rushabh Mehta
pai
commit
1e438a0fad
1 arquivos alterados com 17 adições e 3 exclusões
  1. +17
    -3
      frappe/build.py

+ 17
- 3
frappe/build.py Ver arquivo

@@ -7,6 +7,7 @@ import warnings


from six import iteritems, text_type from six import iteritems, text_type
import subprocess import subprocess
from distutils.spawn import find_executable


""" """
Build the `public` folders and setup languages Build the `public` folders and setup languages
@@ -24,23 +25,36 @@ def setup():
except ImportError: pass except ImportError: pass
app_paths = [os.path.dirname(pymodule.__file__) for pymodule in pymodules] app_paths = [os.path.dirname(pymodule.__file__) for pymodule in pymodules]


def get_node_pacman():
pacmans = ['npm', 'yarn']
for exec_ in pacmans:
exec_ = find_executable(exec_)
if exec_:
return exec_
raise ValueError('No Node.js Package Manager found.')

def bundle(no_compress, make_copy=False, restore=False, verbose=False): def bundle(no_compress, make_copy=False, restore=False, verbose=False):
"""concat / minify js files""" """concat / minify js files"""
setup() setup()
make_asset_dirs(make_copy=make_copy, restore=restore) make_asset_dirs(make_copy=make_copy, restore=restore)


pacman = get_node_pacman()

command = '{pacman} run build'.format(pacman=pacman) if no_compress else '{pacman} run production'.format(pacman=pacman)
frappe_app_path = os.path.abspath(os.path.join(app_paths[0], '..'))
check_yarn() check_yarn()
command = 'yarn run build' if no_compress else 'yarn run production'
frappe_app_path = frappe.get_app_path('frappe', '..')
frappe.commands.popen(command, cwd=frappe_app_path) frappe.commands.popen(command, cwd=frappe_app_path)


def watch(no_compress): def watch(no_compress):
"""watch and rebuild if necessary""" """watch and rebuild if necessary"""
setup() setup()


pacman = get_node_pacman()

frappe_app_path = os.path.abspath(os.path.join(app_paths[0], '..'))
check_yarn() check_yarn()
frappe_app_path = frappe.get_app_path('frappe', '..') frappe_app_path = frappe.get_app_path('frappe', '..')
frappe.commands.popen('yarn run watch', cwd = frappe_app_path)
frappe.commands.popen('{pacman} run watch'.format(pacman=pacman), cwd = frappe_app_path)


def check_yarn(): def check_yarn():
from distutils.spawn import find_executable from distutils.spawn import find_executable


Carregando…
Cancelar
Salvar