Skip to content

Commit c0cd906

Browse files
committed
Added .gitattributes and normalized line endings
1 parent 6a4c899 commit c0cd906

4 files changed

Lines changed: 57 additions & 32 deletions

File tree

‎NewModuleTemplate.psd1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
}
4949

5050
RequiredModules = @()
51-
Copyright = 'Copyright (c) 2026 Kael'
51+
Copyright = 'Copyright (c) 2026 Kael Sterling'
5252

5353
}
5454

‎Public/Initialize-GitRepository.ps1‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ function Initialize-GitRepository {
4040

4141
Write-Debug "Git detected at: $($git.Source)"
4242

43+
#
4344
# Write .gitignore
45+
#
4446
Write-Verbose "Writing .gitignore file."
4547
$gitignorePath = Join-Path $ModulePath '.gitignore'
4648

@@ -100,22 +102,44 @@ desktop.ini
100102
*.suo
101103
*.userosscache
102104
*.sln.docstates
103-
104105
'@
105106

106107
Set-Content -Path $gitignorePath -Value $gitignore -Encoding UTF8
107108

109+
#
110+
# Write .gitattributes (silences CRLF/LF warnings)
111+
#
112+
Write-Verbose "Writing .gitattributes file."
113+
$gitattributesPath = Join-Path $ModulePath '.gitattributes'
114+
115+
$gitattributes = @'
116+
# Normalize line endings for all text files
117+
* text=auto eol=lf
118+
119+
# Explicit normalization for PowerShell-related files
120+
*.ps1 text eol=lf
121+
*.psm1 text eol=lf
122+
*.psd1 text eol=lf
123+
*.md text eol=lf
124+
'@
125+
126+
Set-Content -Path $gitattributesPath -Value $gitattributes -Encoding UTF8
127+
128+
#
108129
# Initialize repository
130+
#
109131
Write-Verbose "Running 'git init' inside '$ModulePath'."
110132
Push-Location $ModulePath
111133
git init | Out-Null
112134
Pop-Location
113135

114-
# Stage files
115-
Write-Verbose "Staging initial files."
116-
git -C $ModulePath add . | Out-Null
136+
# Apply .gitattributes normalization immediately
137+
Write-Verbose "Applying .gitattributes normalization."
138+
git -C $ModulePath add --renormalize . | Out-Null
117139

140+
#
118141
# Commit
142+
#
119143
Write-Verbose "Creating initial commit."
120144
git -C $ModulePath commit -m "Initial commit" | Out-Null
121145

‎Public/New-ModuleTemplate.ps1‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ function New-ModuleTemplate {
8484
$moduleRootPath = Join-Path $Path $Name
8585

8686
# Handle -Force overwrite
87-
if (Test-Path $moduleRootPath -and -not $Force) {
87+
$moduleExists = Test-Path $moduleRootPath
88+
if ($moduleExists -and -not $Force) {
89+
8890
throw "Module path '$moduleRootPath' already exists. Use -Force to overwrite."
8991
}
9092

‎README.md‎

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ Creates complete, production‑ready module structures with tests, documentation
2828

2929
The scaffolder can generate files that integrate with the following tools:
3030

31-
- **Pester** – for running tests
32-
- **PlatyPS** – for generating documentation
33-
- **PSScriptAnalyzer** – for linting and best practices
31+
- **Pester** – for running tests
32+
- **PlatyPS** – for generating documentation
33+
- **PSScriptAnalyzer** – for linting and best practices
3434

3535
These tools are not required for the module to function, and are not included when using `-Minimal`.
3636

37-
3837
---
3938

4039
## 📚 Documentation
@@ -76,44 +75,44 @@ Once installed and imported, you can generate a new PowerShell module scaffold u
7675

7776
Creates a complete, production‑ready module structure:
7877

79-
```powershell
80-
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule"
78+
```powershell
79+
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule"
8180
```
8281

8382
This generates:
8483

85-
* Public/Private folders
86-
* Tests
87-
* Docs
88-
* Analyzer settings
89-
* Build & publish scripts
90-
* Git initialization
91-
* Manifest, loader, README, changelog
84+
- Public/Private folders
85+
- Tests
86+
- Docs
87+
- Analyzer settings
88+
- Build & publish scripts
89+
- Git initialization
90+
- Manifest, loader, README, changelog
9291

9392
### **Minimal Mode**
9493

9594
Creates only the essential module components:
9695

97-
```powershell
98-
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -Minimal
96+
```powershell
97+
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -Minimal
9998
```
10099

101100
Minimal mode includes:
102101

103-
* Public/Private folders
104-
* Manifest
105-
* Loader
106-
* README
107-
* CHANGELOG
102+
- Public/Private folders
103+
- Manifest
104+
- Loader
105+
- README
106+
- CHANGELOG
108107

109108
No Git, no tests, no docs, no analyzer, no scripts.
110109

111110
### **Overwriting Existing Files**
112111

113112
If the module folder already exists, you can refresh the scaffolding files:
114113

115-
```powershell
116-
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -Force
114+
```powershell
115+
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -Force
117116
```
118117

119118
`-Force` overwrites only the files generated by the scaffolder. It does **not** delete your module or remove custom code.
@@ -122,19 +121,19 @@ New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -Force
122121

123122
You can selectively disable parts of the full scaffold:
124123

125-
```powershell
126-
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -NoTests -NoDocs -NoAnalyzer -NoScripts
124+
```powershell
125+
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -NoTests -NoDocs -NoAnalyzer -NoScripts
127126
```
128127

129128
### **Disabling Git Initialization**
130129

131130
Git is enabled by default in full mode. To disable it:
132131

133132
```powershell
134-
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -NoGit
133+
New-ModuleTemplate -Path "C:\\Projects" -Name "MyModule" -NoGit
135134
```
136135

137-
Git is always disabled in minimal mode.
136+
Git is always disabled in minimal mode.
138137

139138
---
140139

0 commit comments

Comments
 (0)