-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
function Print-Message { | ||
param ( | ||
[string]$Message | ||
) | ||
$GREEN = "Green" | ||
$RESET = "White" | ||
Write-Host $Message -ForegroundColor $GREEN | ||
} | ||
|
||
$BUILD = $false | ||
$INSTALL_VENV = $false | ||
$COMMAND_ARGS = @() | ||
|
||
# Parse arguments | ||
foreach ($arg in $args) { | ||
switch ($arg) { | ||
'-b' { | ||
$BUILD = $true | ||
} | ||
'--install-venv' { | ||
$INSTALL_VENV = $true | ||
} | ||
default { | ||
$COMMAND_ARGS += $arg | ||
} | ||
} | ||
} | ||
|
||
# Check for virtual environment | ||
if (-not (Test-Path "venv")) { | ||
$INSTALL_VENV = $true | ||
Print-Message "Virtual environment not found." | ||
} | ||
|
||
# Install or rebuild virtual environment if needed | ||
if ($INSTALL_VENV -eq $true) { | ||
if (Test-Path "venv") { | ||
Print-Message "Removing existing virtual environment..." | ||
Remove-Item -Recurse -Force "venv" | ||
} | ||
|
||
Print-Message "Installing virtual environment..." | ||
python -m venv venv | ||
Print-Message "Installing dependencies..." | ||
& "./venv/Scripts/pip" install -r requirements.txt | ||
} | ||
|
||
# Determine command based on build flag | ||
$COMMAND = "serve" | ||
if ($BUILD -eq $true) { | ||
$COMMAND = "build" | ||
} | ||
|
||
# Run mkdocs with the determined command and arguments | ||
& "./venv/Scripts/mkdocs" $COMMAND $ARGS |