@10stars/config 15.0.11 → 15.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@10stars/config",
3
- "version": "15.0.11",
3
+ "version": "15.0.12",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "config": "./src/index.ts"
@@ -2,6 +2,12 @@ import fs from "node:fs/promises"
2
2
  import path from "node:path"
3
3
  import { execSync } from "node:child_process"
4
4
 
5
+ // Strip JSONC comments while preserving strings (regex matches strings first to skip them)
6
+ const stripJsoncComments = (jsonc: string): string =>
7
+ jsonc.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (match) =>
8
+ match.startsWith("/") ? "" : match,
9
+ )
10
+
5
11
  const extensionsJson = {
6
12
  recommendations: ["oxc.oxc-vscode"],
7
13
  unwantedRecommendations: [
@@ -94,10 +100,9 @@ export const setupVSCode = async (cwd: string) => {
94
100
  let existingSettings: Record<string, unknown> = {}
95
101
  try {
96
102
  const existingContent = await fs.readFile(settingsPath, "utf8")
97
- // Strip comments (JSONC support)
98
- const jsonWithoutComments = existingContent.replace(/\/\/.*|\/\*[\s\S]*?\*\//g, "")
99
- existingSettings = JSON.parse(jsonWithoutComments)
100
- } catch {
103
+ existingSettings = JSON.parse(stripJsoncComments(existingContent))
104
+ } catch (error) {
105
+ console.error("Error reading or parsing settings.json:", error)
101
106
  // File doesn't exist or is invalid JSON, start fresh
102
107
  }
103
108