From 56e64efd67d9893e4d093a91660ff0f31867b717 Mon Sep 17 00:00:00 2001 From: Quentin Brunet Date: Wed, 15 Jun 2022 14:27:30 +0200 Subject: [PATCH] Fix the npm/yarn install for mac users --- CHANGELOG.md | 1 + invoke.py | 3 +++ tasks.py | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e94e1f6..9cb95df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Add documentation cookbook for using pg_activity * Forward CI env vars in Docker containers +* Run the npm/yarn/webpack commands on the host for all mac users (even the ones not using Dinghy) ## 3.7.0 (2022-05-24) diff --git a/invoke.py b/invoke.py index d30106a..a0652a6 100644 --- a/invoke.py +++ b/invoke.py @@ -20,6 +20,7 @@ 'builder', ] dinghy = False +macos = False power_shell = False user_id = 1000 root_dir = '.' @@ -46,6 +47,8 @@ def __extract_runtime_configuration(config): config['composer_cache_dir'] = composer_cache_dir_from_host.strip() if platform == "darwin": + config['macos'] = True + try: docker_kernel = run('docker version --format "{{.Server.KernelVersion}}"', hide=True).stdout except: diff --git a/tasks.py b/tasks.py index ea46bcd..3022680 100644 --- a/tasks.py +++ b/tasks.py @@ -68,9 +68,9 @@ def install(c): if os.path.isfile(c.root_dir + '/' + c.project_directory + '/composer.json'): docker_compose_run(c, 'composer install -n --prefer-dist --optimize-autoloader', no_deps=True) if os.path.isfile(c.root_dir + '/' + c.project_directory + '/yarn.lock'): - run_in_docker_or_locally_for_dinghy(c, 'yarn', no_deps=True) + run_in_docker_or_locally_for_mac(c, 'yarn', no_deps=True) elif os.path.isfile(c.root_dir + '/' + c.project_directory + '/package.json'): - run_in_docker_or_locally_for_dinghy(c, 'npm install', no_deps=True) + run_in_docker_or_locally_for_mac(c, 'npm install', no_deps=True) @task @@ -244,11 +244,11 @@ def generate_certificates(c, force=False): print('Please restart the infrastructure to use the new certificates with "inv up" or "inv start".') -def run_in_docker_or_locally_for_dinghy(c, command, no_deps=False): +def run_in_docker_or_locally_for_mac(c, command, no_deps=False): """ Mac users have a lot of problems running Yarn / Webpack on the Docker stack so this func allow them to run these tools on their host """ - if c.dinghy: + if c.macos: with c.cd(c.project_directory): c.run(command) else: