Skip to content

Commit e9ccd44

Browse files
committed
Improve comments and formatting of code
1 parent 9ea35d6 commit e9ccd44

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/Compile-SourceScript/Public/Compile-SourceScript.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ function Compile-SourceScript {
134134
)
135135
}
136136
New-Item -Path $COMPILED_DIR -ItemType Directory -Force | Out-Null
137+
137138
# Begin compilation
138139
if ($PSBoundParameters['SkipWrapper']) { "Compiling $($sourceFile.Name)..." | Write-Host -ForegroundColor Yellow }
139140
Start-Process @processArgs
@@ -164,19 +165,25 @@ function Compile-SourceScript {
164165

165166
New-Item -Path $PLUGINS_DIR -ItemType Directory -Force | Out-Null
166167
$installationFailure = $false
168+
167169
$compiledDirItemsDiff | % {
170+
171+
# Display info for the compiled plugin
168172
"`n$($_.Name):" | Write-Host -ForegroundColor Green
169173
if ($_.Basename -ne $sourceFile.Basename) {
170174
" The plugin's name does not match the specified script's name. The plugin will not copied to the plugins directory." | Write-Host -ForegroundColor Yellow
171175
return # continue in %
172176
}
177+
178+
# Check for an existing plugin
173179
$existingPlugin = Get-Item -Path "$PLUGINS_DIR/$($_.Name)" -ErrorAction SilentlyContinue
174180
if (!$existingPlugin) {
175181
" Plugin does not currently exist in the plugins directory." | Write-Host -ForegroundColor Yellow
176182
}else {
177183
$existingPluginHash = (Get-FileHash -Path $existingPlugin -Algorithm MD5).Hash
178184
" Existing: $($existingPlugin.LastWriteTime), $existingPluginHash" | Write-Host -ForegroundColor Yellow
179185
}
186+
180187
# Display the compiled and existing plugin's file info
181188
$compiledPluginHash = (Get-FileHash -Path $_.FullName -Algorithm MD5).Hash
182189
" Compiled: $($_.LastWriteTime), $compiledPluginHash" | Write-Host -ForegroundColor Green
@@ -196,6 +203,8 @@ function Compile-SourceScript {
196203
if ($updatedPluginHash -eq $compiledPluginHash) { "`n Plugin successfully copied to '$($_.Fullname)'" | Write-Host -ForegroundColor Green }
197204
else { "`n Failed to copy to the plugins directory." | Write-Host -ForegroundColor Magenta; return }
198205
}
206+
207+
# Throw an error if the copying process failed
199208
if ($installationFailure) {
200209
throw "Failed to install one or more plugins."
201210
}
@@ -212,4 +221,5 @@ function Compile-SourceScript {
212221
"End of Compile-SourceScript." | Write-Host -ForegroundColor Cyan
213222
}
214223
}
224+
215225
}

0 commit comments

Comments
 (0)