Skip to content

Commit e6dd0e4

Browse files
Fix bom in json (#46)
* Fix BOM issue in package.json by using Node.js for file writing Replace PowerShell file writing with Node.js to ensure UTF-8 without BOM. This prevents npm install failures caused by BOM in package.json files.
1 parent 26f8ecc commit e6dd0e4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<!-- default badges list -->
2-
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/340354634/25.1.2%2B)
32
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T1129779)
43
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
54
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)

test-example.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,11 @@ function Process-AspNetCoreProject {
229229
}
230230

231231
if ($updated) {
232-
#$packageJson | ConvertTo-Json -Depth 10 | Set-Content -Path $packageJsonPath -Encoding UTF8
232+
$tempJsonPath = [System.IO.Path]::GetTempFileName()
233233
$jsonContent = $packageJson | ConvertTo-Json -Depth 10
234-
[System.IO.File]::WriteAllText($packageJsonPath, $jsonContent, [System.Text.UTF8Encoding]::new($false))
234+
[System.IO.File]::WriteAllText($tempJsonPath, $jsonContent, [System.Text.UTF8Encoding]::new($false))
235+
node -e "const fs = require('fs'); const data = fs.readFileSync('$($tempJsonPath -replace '\\', '/')', 'utf8'); fs.writeFileSync('$($packageJsonPath -replace '\\', '/')', data, 'utf8');"
236+
Remove-Item $tempJsonPath -ErrorAction SilentlyContinue
235237
Write-Host "Updated package.json with valid versions."
236238
} else {
237239
Write-Host "No matching dependencies found in package.json to update."

0 commit comments

Comments
 (0)