File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,18 @@ export const test = base.extend<TestFixtures>({
5555 const vscodeDir = path . join ( projectDir , ".vscode" ) ;
5656 fs . ensureDirSync ( vscodeDir ) ;
5757 const settingsPath = path . join ( vscodeDir , "settings.json" ) ;
58- const existingSettings = fs . existsSync ( settingsPath )
59- ? JSON . parse ( fs . readFileSync ( settingsPath , "utf-8" ) )
60- : { } ;
58+ let existingSettings : Record < string , unknown > = { } ;
59+ if ( fs . existsSync ( settingsPath ) ) {
60+ // settings.json may contain JS-style comments (JSONC), strip them before parsing
61+ const raw = fs . readFileSync ( settingsPath , "utf-8" ) ;
62+ const stripped = raw . replace ( / \/ \/ .* $ / gm, "" ) . replace ( / \/ \* [ \s \S ] * ?\* \/ / g, "" ) ;
63+ try {
64+ existingSettings = JSON . parse ( stripped ) ;
65+ } catch {
66+ // If still invalid, start fresh — our injected settings are more important
67+ existingSettings = { } ;
68+ }
69+ }
6170 const mergedSettings = {
6271 ...existingSettings ,
6372 "telemetry.telemetryLevel" : "off" ,
You can’t perform that action at this time.
0 commit comments