-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_homey_remote_with_log.ps1
More file actions
43 lines (35 loc) · 1.1 KB
/
Copy pathrun_homey_remote_with_log.ps1
File metadata and controls
43 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
param(
[string]$LogDirectory = (Join-Path $PSScriptRoot ".homey-run-logs"),
[switch]$SkipBuild
)
$ErrorActionPreference = "Stop"
$appDir = Join-Path $PSScriptRoot "no.tiwas.booleantoolbox"
if (-not (Test-Path (Join-Path $appDir "app.json"))) {
throw "Could not find Homey app manifest at '$appDir'."
}
New-Item -ItemType Directory -Force -Path $LogDirectory | Out-Null
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$logFile = Join-Path $LogDirectory "homey-app-run-$timestamp.log"
$homeyArgs = @("app", "run", "--remote")
if ($SkipBuild) {
$homeyArgs += "--skip-build"
}
$exitCode = 0
$header = @(
"Homey remote run log",
"Started: $(Get-Date -Format o)",
"AppDir: $appDir",
"Command: homey $($homeyArgs -join ' ')",
""
)
$header | Tee-Object -FilePath $logFile
Push-Location $appDir
try {
& homey @homeyArgs 2>&1 | Tee-Object -FilePath $logFile -Append
$exitCode = $LASTEXITCODE
} finally {
Pop-Location
"`nEnded: $(Get-Date -Format o)" | Tee-Object -FilePath $logFile -Append
"Log file: $logFile" | Tee-Object -FilePath $logFile -Append
}
exit $exitCode