-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodablellm.ps1
More file actions
50 lines (43 loc) · 2.31 KB
/
Copy pathcodablellm.ps1
File metadata and controls
50 lines (43 loc) · 2.31 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
44
45
46
47
48
49
50
# Get the script's current directory
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
# Initialize an array to store updated arguments for Docker
$updatedArgs = @()
# Process each argument (file or directory)
foreach ($arg in $args) {
# If the argument is a flag (e.g., --help) or a non-file argument (e.g., arg1), just add it to updatedArgs as is
if ((Test-Path $arg -PathType Leaf -ErrorAction SilentlyContinue) -eq $false) {
Write-Host "Adding argument '$arg' to arguments."
$updatedArgs += $arg
} else {
# Get the full absolute path of the argument
$filePath = Resolve-Path -Path $arg -ErrorAction SilentlyContinue
# Check if the file or directory exists
if (Test-Path $filePath) {
# Check if the file is already in the script directory
$destinationPath = Join-Path -Path $scriptDirectory -ChildPath (Split-Path -Leaf $filePath)
if ($filePath -ne $destinationPath) {
# If the file is not already in the script directory, copy it
if (-not (Test-Path $destinationPath)) {
Write-Host "Copying '$filePath' to '$destinationPath'..."
Copy-Item -Path $filePath -Destination $destinationPath
} else {
Write-Host "'$filePath' already exists in the script directory. Skipping."
}
# Add the destination path (relative to the script directory) to the updated arguments
$updatedArgs += "./" + (Split-Path -Leaf $filePath)
} else {
Write-Host "'$filePath' is already in the script directory. Skipping."
# If the file is already in the script directory, add it as-is to the updated arguments
$updatedArgs += "./" + (Split-Path -Leaf $filePath)
}
} else {
Write-Host "The file or directory '$filePath' does not exist. Skipping."
# If the file or directory doesn't exist, add the original argument as-is
$updatedArgs += $arg
}
}
}
# Print the updated arguments (for debugging)
Write-Host "Updated Arguments: $($updatedArgs -join ', ')"
# Run the container for the app using docker-compose with updated arguments
docker-compose run --rm app codablellm @updatedArgs