Skip to content

Commit 3908307

Browse files
committed
chore: Update to the latest devcontainer image
chore: Install CSpell if needed feat: Add VS Code tasks to run CSpell locally
1 parent 34c8942 commit 3908307

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

.cspell.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"**/_.gitignore",
1111
"**/devcontainer.json",
1212
"**/build-and-test-powershell-module.yml",
13-
"**/build-test-and-deploy-powershell-module.yml"
13+
"**/build-test-and-deploy-powershell-module.yml",
14+
"**/bin/**", // Ignore C# build output files.
15+
"**/obj/**" // Ignore C# build output files.
1416
],
1517
"words": [
1618
"behaviour",

.devcontainer/devcontainer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "PowerShell",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/powershell:lts-debian-11",
6+
"image": "mcr.microsoft.com/dotnet/sdk:9.0",
77
"features": {
88
"ghcr.io/devcontainers/features/common-utils:2": {
99
"installZsh": "true",
@@ -13,8 +13,9 @@
1313
}
1414
},
1515

16-
// Set VS Code's default shell to PowerShell.
17-
"postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\"",
16+
// Set pwsh as the default shell for the devcontainer, install required PowerShell modules, and install NPM and CSpell.
17+
// If you do not plan to use CSpell, you can remove everything after and including 'sudo apt update'.
18+
"postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\"; pwsh -c \"Install-Module Pester -Force\"; pwsh -c \"Install-Module PSScriptAnalyzer -Force\"; sudo apt update; sudo DEBIAN_FRONTEND=noninteractive apt install -y npm; npm install cspell",
1819

1920
// Configure tool-specific properties.
2021
"customizations": {

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Custom additions:
2+
3+
# Ignore NPM files.
4+
package-lock.json
5+
package.json
6+
17
# Created by https://www.toptal.com/developers/gitignore/api/powershell,visualstudiocode,visualstudio
28
# Edit at https://www.toptal.com/developers/gitignore?templates=powershell,visualstudiocode,visualstudio
39

.vscode/tasks.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"isDefault": true
1010
},
1111
"dependsOn": [
12-
"Run PSScriptAnalyzer linter"
12+
"Run PSScriptAnalyzer linter",
13+
"Run CSpell spell checker"
1314
]
1415
},
1516
{
@@ -46,6 +47,31 @@
4647
"$func-powershell-watch"
4748
]
4849
},
50+
{
51+
"label": "Run CSpell spell checker",
52+
"type": "shell",
53+
"options": {
54+
"shell": {
55+
"executable": "pwsh",
56+
"args": [
57+
"-NoProfile",
58+
"-Command"
59+
]
60+
}
61+
},
62+
// If npx is not available, warn that Node.js is not installed. If we cannot run cspell, try to install and run it, and warn if we still cannot run it.
63+
"command": "try { & npx -v > $null } catch {}; if (-not $?) { Write-Warning 'Node.js is not installed, so cannot download and run npx cspell.' } else { try { & npx cspell . } catch {}; if (-not $?) { & npm install cspell; & npx cspell . }; if (-not $?) { Write-Warning 'There was a problem installing or running cspell' } }",
64+
"group": "build",
65+
"presentation": {
66+
"reveal": "always",
67+
"panel": "dedicated",
68+
"clear": true,
69+
"group": "build"
70+
},
71+
"problemMatcher": [
72+
"$func-powershell-watch"
73+
]
74+
},
4975
{
5076
"label": "Run all Pester tests",
5177
"type": "shell",

src/ScriptModuleRepositoryTemplate/TemplateRepoFiles/_.cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"language": "en",
88
"ignorePaths": [
99
".devcontainer/devcontainer.json",
10-
".github/workflows/*.yml"
10+
".github/workflows/*.yml",
11+
".gitignore"
1112
],
1213
"words": [
1314
"behaviour",

0 commit comments

Comments
 (0)