microsoft/hve-core

Public

mirrored from https://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
feat/devcontainer-python-uv-887

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/skills/installer/hve-core-installer/scripts/detect-environment.ps1

47lines · modecode

1# Copyright (c) Microsoft Corporation.
2# SPDX-License-Identifier: MIT
3<#
4.SYNOPSIS
5 Detects the current development environment for HVE-Core installation.
6.DESCRIPTION
7 Identifies whether the user is in a local VS Code, devcontainer, or Codespaces
8 environment and reports relevant configuration details.
9.EXAMPLE
10 ./scripts/detect-environment.ps1
11.OUTPUTS
12 Key-value pairs: ENV_TYPE, IS_CODESPACES, IS_DEVCONTAINER,
13 HAS_DEVCONTAINER_JSON, HAS_WORKSPACE_FILE, IS_HVE_CORE_REPO.
14#>
15[CmdletBinding()]
16param()
17
18$ErrorActionPreference = 'Stop'
19
20# Detect environment type
21$env_type = "local"
22$is_codespaces = $false
23$is_devcontainer = $false
24
25if ($env:CODESPACES -eq "true") {
26 $env_type = "codespaces"
27 $is_codespaces = $true
28 $is_devcontainer = $true
29} elseif ((Test-Path "/.dockerenv") -or ($env:REMOTE_CONTAINERS -eq "true")) {
30 $env_type = "devcontainer"
31 $is_devcontainer = $true
32}
33
34$has_devcontainer_json = Test-Path ".devcontainer/devcontainer.json"
35$has_workspace_file = (Get-ChildItem -Filter "*.code-workspace" -ErrorAction SilentlyContinue | Measure-Object).Count -gt 0
36try {
37 $is_hve_core_repo = (Split-Path (git rev-parse --show-toplevel 2>$null) -Leaf) -eq "hve-core"
38} catch {
39 $is_hve_core_repo = $false
40}
41
42Write-Host "ENV_TYPE=$env_type"
43Write-Host "IS_CODESPACES=$is_codespaces"
44Write-Host "IS_DEVCONTAINER=$is_devcontainer"
45Write-Host "HAS_DEVCONTAINER_JSON=$has_devcontainer_json"
46Write-Host "HAS_WORKSPACE_FILE=$has_workspace_file"
47Write-Host "IS_HVE_CORE_REPO=$is_hve_core_repo"
48