From bef6591548607616d70a3cc1110fd3b8b120977d Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sat, 12 Feb 2022 07:30:19 +0100 Subject: [PATCH] Add WORKSPACE_DIRECTORY environment variable to devcontainer and script.core (#11477) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joakim Sørensen --- .devcontainer/devcontainer.json | 3 +++ script/core | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 977620c9dd..746fa30697 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -16,6 +16,9 @@ "runem.lit-plugin", "ms-python.vscode-pylance" ], + "containerEnv": { + "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" + }, "settings": { "terminal.integrated.shell.linux": "/bin/bash", "files.eol": "\n", diff --git a/script/core b/script/core index 00d663cab2..79ba38a348 100755 --- a/script/core +++ b/script/core @@ -4,6 +4,8 @@ # Stop on errors set -e +WD="${WORKSPACE_DIRECTORY:=/workspaces/frontend}" + if [ -z "${DEVCONTAINER}" ]; then echo "This task should only run inside a devcontainer, for local install HA Core in a venv." exit 1 @@ -16,9 +18,9 @@ if [ -z $(which hass) ]; then git+git://github.com/home-assistant/home-assistant.git@dev fi -if [ ! -d "/workspaces/frontend/config" ]; then +if [ ! -d "${WD}/config" ]; then echo "Creating default configuration." - mkdir -p "/workspaces/frontend/config"; + mkdir -p "${WD}/config"; hass --script ensure_config -c config echo "demo: @@ -26,24 +28,24 @@ logger: default: info logs: homeassistant.components.frontend: debug -" >> /workspaces/frontend/config/configuration.yaml +" >> "${WD}/config/configuration.yaml" if [ ! -z "${HASSIO}" ]; then echo " # frontend: -# development_repo: /workspaces/frontend +# development_repo: ${WD} hassio: - development_repo: /workspaces/frontend" >> /workspaces/frontend/config/configuration.yaml + development_repo: ${WD}" >> "${WD}/config/configuration.yaml" else echo " frontend: - development_repo: /workspaces/frontend + development_repo: ${WD} # hassio: -# development_repo: /workspaces/frontend" >> /workspaces/frontend/config/configuration.yaml +# development_repo: ${WD}" >> "${WD}/config/configuration.yaml" fi fi -hass -c /workspaces/frontend/config +hass -c "${WD}/config"