Skip to content

Commit

Permalink
added powershell run script
Browse files Browse the repository at this point in the history
  • Loading branch information
joapuiib committed Sep 20, 2024
1 parent fb4702a commit 60db671
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions run.ps1
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

0 comments on commit 60db671

Please sign in to comment.