@@ -55,45 +55,59 @@ param(
5555 [switch ] $LeavePackageInstallCache
5656)
5757
58- Set-StrictMode - Version 3.0
59-
60- if (! (Get-Command npm - ErrorAction SilentlyContinue)) {
61- LogError " Could not locate npm. Install NodeJS (includes npm) https://nodejs.org/en/download/"
62- exit 1
63- }
64-
65- if (! (Test-Path $CSpellConfigPath )) {
66- LogError " Could not locate config file $CSpellConfigPath "
67- exit 1
68- }
69-
70- # Prepare the working directory if it does not already have requirements in
71- # place.
72- if (! (Test-Path $PackageInstallCache )) {
73- New-Item - ItemType Directory - Path $PackageInstallCache | Out-Null
58+ begin {
59+ Set-StrictMode - Version 3.0
60+
61+ if (! (Get-Command npm - ErrorAction SilentlyContinue)) {
62+ LogError " Could not locate npm. Install NodeJS (includes npm) https://nodejs.org/en/download/"
63+ exit 1
64+ }
65+
66+ if (! (Test-Path $CSpellConfigPath )) {
67+ LogError " Could not locate config file $CSpellConfigPath "
68+ exit 1
69+ }
70+
71+ # Prepare the working directory if it does not already have requirements in
72+ # place.
73+ if (! (Test-Path $PackageInstallCache )) {
74+ New-Item - ItemType Directory - Path $PackageInstallCache | Out-Null
75+ }
76+
77+ if (! (Test-Path " $PackageInstallCache /package.json" )) {
78+ Copy-Item " $PSScriptRoot /package.json" $PackageInstallCache
79+ }
80+
81+ if (! (Test-Path " $PackageInstallCache /package-lock.json" )) {
82+ Copy-Item " $PSScriptRoot /package-lock.json" $PackageInstallCache
83+ }
84+
85+
86+ $filesToCheck = @ ()
87+ }
88+ process {
89+ $filesToCheck += $FileList
90+ }
91+ end {
92+ npm -- prefix $PackageInstallCache ci | Write-Host
93+
94+ $command = " npm --prefix $PackageInstallCache exec --no -- cspell $JobType --config $CSpellConfigPath --no-must-find-files --root $SpellCheckRoot --file-list stdin"
95+ Write-Host $command
96+ $cspellOutput = $filesToCheck | npm -- prefix $PackageInstallCache `
97+ exec `
98+ -- no `
99+ -- `
100+ cspell `
101+ $JobType `
102+ -- config $CSpellConfigPath `
103+ -- no- must- find-files `
104+ -- root $SpellCheckRoot `
105+ -- file- list stdin
106+
107+ if (! $LeavePackageInstallCache ) {
108+ Write-Host " Cleaning up package install cache at $PackageInstallCache "
109+ Remove-Item - Path $PackageInstallCache - Recurse - Force | Out-Null
110+ }
111+
112+ return $cspellOutput
74113}
75-
76- if (! (Test-Path " $PackageInstallCache /package.json" )) {
77- Copy-Item " $PSScriptRoot /package.json" $PackageInstallCache
78- }
79-
80- if (! (Test-Path " $PackageInstallCache /package-lock.json" )) {
81- Copy-Item " $PSScriptRoot /package-lock.json" $PackageInstallCache
82- }
83-
84- npm -- prefix $PackageInstallCache ci | Write-Host
85-
86- $command = " npm --prefix $PackageInstallCache exec --no -- cspell $JobType --config $CSpellConfigPath --no-must-find-files --root $SpellCheckRoot --file-list stdin"
87- Write-Host $command
88- $cspellOutput = $FileList | npm -- prefix $PackageInstallCache `
89- exec `
90- -- no `
91- -- `
92- cspell `
93- $JobType `
94- -- config $CSpellConfigPath `
95- -- no- must- find-files `
96- -- root $SpellCheckRoot `
97- -- file- list stdin
98-
99- return $cspellOutput
0 commit comments