Skip to content

Commit 40653d3

Browse files
committed
fix: try to fix windows script
1 parent e6999f5 commit 40653d3

1 file changed

Lines changed: 48 additions & 39 deletions

File tree

scripts/install.ps1

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,90 @@
11
# TimeTree installation script for Windows PowerShell
22
# This script builds and installs timetree and tt commands
33

4-
$ErrorActionPreference = "Stop"
4+
$ErrorActionPreference = 'Stop'
55

66
# Get script directory and project root
7-
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
7+
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
88
$ProjectRoot = Split-Path -Parent $ScriptDir
99

1010
# Change to project root
1111
Set-Location $ProjectRoot
1212

13-
Write-Host "Building TimeTree..." -ForegroundColor Green
13+
Write-Host 'Building TimeTree...' -ForegroundColor Green
1414
& .\gradlew.bat shadowJar --no-daemon
1515
if ($LASTEXITCODE -ne 0) {
16-
Write-Host "Error: Failed to build TimeTree" -ForegroundColor Red
16+
Write-Host 'Error: Failed to build TimeTree' -ForegroundColor Red
1717
exit 1
1818
}
1919

20-
$JarFile = Join-Path $ProjectRoot "build\libs\timetree.jar"
20+
$JarFile = Join-Path $ProjectRoot 'build\libs\timetree.jar'
2121

2222
# Check if JAR exists
2323
if (-not (Test-Path $JarFile)) {
24-
Write-Host "Error: timetree.jar not found at $JarFile" -ForegroundColor Red
24+
Write-Host ('Error: timetree.jar not found at ' + $JarFile) -ForegroundColor Red
2525
exit 1
2626
}
2727

2828
# Determine installation directory
29-
$InstallDir = Join-Path $env:LOCALAPPDATA "TimeTree\bin"
29+
$InstallDir = Join-Path $env:LOCALAPPDATA 'TimeTree\bin'
3030
if (-not (Test-Path $InstallDir)) {
3131
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
3232
}
3333

34-
Write-Host "Installing timetree to $InstallDir..." -ForegroundColor Green
34+
Write-Host ('Installing timetree to ' + $InstallDir + '...') -ForegroundColor Green
3535

3636
# Create wrapper batch file for timetree
37-
$TimetreeBat = @'
38-
@echo off
39-
REM TimeTree wrapper script
40-
set "JAR_FILE=%~dp0timetree.jar"
41-
java -jar "%JAR_FILE%" %*
42-
'@
43-
$TimetreeBat | Out-File -FilePath (Join-Path $InstallDir "timetree.bat") -Encoding ASCII
37+
$TimetreeBatLines = @(
38+
'@echo off'
39+
'REM TimeTree wrapper script'
40+
'set "JAR_FILE=%~dp0timetree.jar"'
41+
'java -jar "%JAR_FILE%" %*'
42+
)
43+
$TimetreeBat = $TimetreeBatLines -join "`r`n"
44+
$TimetreeBat | Out-File -FilePath (Join-Path $InstallDir 'timetree.bat') -Encoding ASCII -NoNewline
4445

4546
# Copy the JAR file
46-
Copy-Item $JarFile (Join-Path $InstallDir "timetree.jar") -Force
47+
Copy-Item $JarFile (Join-Path $InstallDir 'timetree.jar') -Force
4748

4849
# Create tt.bat wrapper
49-
$TtBat = @'
50-
@echo off
51-
REM TimeTree 'tt' wrapper script
52-
set "JAR_FILE=%~dp0timetree.jar"
53-
java -jar "%JAR_FILE%" %*
54-
'@
55-
$TtBat | Out-File -FilePath (Join-Path $InstallDir "tt.bat") -Encoding ASCII
50+
$TtBatLines = @(
51+
'@echo off'
52+
'REM TimeTree ''tt'' wrapper script'
53+
'set "JAR_FILE=%~dp0timetree.jar"'
54+
'java -jar "%JAR_FILE%" %*'
55+
)
56+
$TtBat = $TtBatLines -join "`r`n"
57+
$TtBat | Out-File -FilePath (Join-Path $InstallDir 'tt.bat') -Encoding ASCII -NoNewline
5658

57-
Write-Host "✓ Successfully installed timetree and tt to $InstallDir" -ForegroundColor Green
59+
Write-Host ('✓ Successfully installed timetree and tt to ' + $InstallDir) -ForegroundColor Green
5860

5961
# Check if directory is in PATH
60-
$CurrentPath = [Environment]::GetEnvironmentVariable("Path", "User")
61-
if ($CurrentPath -notlike "*$InstallDir*") {
62-
Write-Host ""
63-
Write-Host "Warning: $InstallDir is not in your PATH" -ForegroundColor Yellow
64-
Write-Host "Add this directory to your PATH:" -ForegroundColor Yellow
62+
$CurrentPath = [Environment]::GetEnvironmentVariable('Path', 'User')
63+
if ($CurrentPath -notlike ('*' + $InstallDir + '*')) {
64+
Write-Host ''
65+
Write-Host ('Warning: ' + $InstallDir + ' is not in your PATH') -ForegroundColor Yellow
66+
Write-Host 'Add this directory to your PATH:' -ForegroundColor Yellow
6567
Write-Host " 1. Press Win+R, type 'sysdm.cpl' and press Enter" -ForegroundColor Yellow
6668
Write-Host " 2. Go to 'Advanced' tab, click 'Environment Variables'" -ForegroundColor Yellow
6769
Write-Host " 3. Under 'User variables', select 'Path' and click 'Edit'" -ForegroundColor Yellow
68-
Write-Host " 4. Click 'New' and add: $InstallDir" -ForegroundColor Yellow
69-
Write-Host " 5. Click OK on all dialogs" -ForegroundColor Yellow
70-
Write-Host ""
71-
Write-Host "Or add to PATH with this PowerShell command:" -ForegroundColor Yellow
70+
Write-Host (' 4. Click ''New'' and add: ' + $InstallDir) -ForegroundColor Yellow
71+
Write-Host ' 5. Click OK on all dialogs' -ForegroundColor Yellow
72+
Write-Host ''
73+
Write-Host 'Or add to PATH with this PowerShell command:' -ForegroundColor Yellow
7274

73-
$PathCommand = "[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path','User') + ';$InstallDir', 'User')"
74-
Write-Host " $PathCommand" -ForegroundColor Green
75+
# Build a literal command string with doubled single-quotes for embedding
76+
$PathCommand = (
77+
'[Environment]::SetEnvironmentVariable(''Path'', ' +
78+
'[Environment]::GetEnvironmentVariable(''Path'',''User'') + '';' +
79+
$InstallDir +
80+
''', ''User'')'
81+
)
82+
83+
Write-Host (' ' + $PathCommand) -ForegroundColor Green
7584
} else {
76-
Write-Host "+ $InstallDir is already in your PATH" -ForegroundColor Green
85+
Write-Host ('+ ' + $InstallDir + ' is already in your PATH') -ForegroundColor Green
7786
}
7887

79-
Write-Host ""
80-
Write-Host "Installation complete! You can now use 'timetree' and 'tt' commands." -ForegroundColor Green
81-
Write-Host "Note: You may need to restart your terminal for PATH changes to take effect." -ForegroundColor Yellow
88+
Write-Host ''
89+
Write-Host 'Installation complete! You can now use ''timetree'' and ''tt'' commands.' -ForegroundColor Green
90+
Write-Host 'Note: You may need to restart your terminal for PATH changes to take effect.' -ForegroundColor Yellow

0 commit comments

Comments
 (0)