File tree Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ require (
45
45
github.com/spf13/viper v1.19.0
46
46
github.com/stretchr/testify v1.10.0
47
47
github.com/stripe/pg-schema-diff v0.8.0
48
+ github.com/tidwall/jsonc v0.3.2
48
49
github.com/withfig/autocomplete-tools/packages/cobra v1.2.0
49
50
github.com/zalando/go-keyring v0.2.6
50
51
go.opentelemetry.io/otel v1.33.0
Original file line number Diff line number Diff line change @@ -946,6 +946,8 @@ github.com/tetafro/godot v1.4.20 h1:z/p8Ek55UdNvzt4TFn2zx2KscpW4rWqcnUrdmvWJj7E=
946
946
github.com/tetafro/godot v1.4.20 /go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio =
947
947
github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c =
948
948
github.com/theupdateframework/notary v0.7.0 /go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw =
949
+ github.com/tidwall/jsonc v0.3.2 h1:ZTKrmejRlAJYdn0kcaFqRAKlxxFIC21pYq8vLa4p2Wc =
950
+ github.com/tidwall/jsonc v0.3.2 /go.mod h1:dw+3CIxqHi+t8eFSpzzMlcVYxKp08UP5CD8/uSFCyJE =
949
951
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 h1:y4mJRFlM6fUyPhoXuFg/Yu02fg/nIPFMOY8tOqppoFg =
950
952
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 /go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460 =
951
953
github.com/timonwong/loggercheck v0.10.1 h1:uVZYClxQFpw55eh+PIoqM7uAOHMrhVcDoWDery9R8Lg =
Original file line number Diff line number Diff line change 1
1
package init
2
2
3
3
import (
4
+ "bytes"
4
5
"context"
5
6
_ "embed"
6
7
"encoding/json"
@@ -12,6 +13,7 @@ import (
12
13
"github.com/go-errors/errors"
13
14
"github.com/spf13/afero"
14
15
"github.com/supabase/cli/internal/utils"
16
+ "github.com/tidwall/jsonc"
15
17
)
16
18
17
19
var (
@@ -100,15 +102,14 @@ func updateGitIgnore(ignorePath string, fsys afero.Fs) error {
100
102
type VSCodeSettings map [string ]interface {}
101
103
102
104
func loadUserSettings (path string , fsys afero.Fs ) (VSCodeSettings , error ) {
103
- // Open our jsonFile
104
- jsonFile , err := fsys .Open (path )
105
+ data , err := afero .ReadFile (fsys , path )
105
106
if err != nil {
106
107
return nil , errors .Errorf ("failed to load settings file: %w" , err )
107
108
}
108
- defer jsonFile . Close ( )
109
+ data = jsonc . ToJSONInPlace ( data )
109
110
// Parse and unmarshal JSON file.
110
111
var userSettings VSCodeSettings
111
- dec := json .NewDecoder (jsonFile )
112
+ dec := json .NewDecoder (bytes . NewReader ( data ) )
112
113
if err := dec .Decode (& userSettings ); err != nil {
113
114
return nil , errors .Errorf ("failed to parse settings: %w" , err )
114
115
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
19
19
20
20
"github.com/go-errors/errors"
21
21
"github.com/spf13/afero"
22
+ "github.com/tidwall/jsonc"
22
23
)
23
24
24
25
var (
@@ -215,13 +216,13 @@ type ImportMap struct {
215
216
}
216
217
217
218
func NewImportMap (absJsonPath string , fsys afero.Fs ) (* ImportMap , error ) {
218
- contents , err := fsys . Open ( absJsonPath )
219
+ data , err := afero . ReadFile ( fsys , absJsonPath )
219
220
if err != nil {
220
221
return nil , errors .Errorf ("failed to load import map: %w" , err )
221
222
}
222
- defer contents . Close ( )
223
+ data = jsonc . ToJSONInPlace ( data )
223
224
result := ImportMap {}
224
- decoder := json .NewDecoder (contents )
225
+ decoder := json .NewDecoder (bytes . NewReader ( data ) )
225
226
if err := decoder .Decode (& result ); err != nil {
226
227
return nil , errors .Errorf ("failed to parse import map: %w" , err )
227
228
}
You can’t perform that action at this time.
0 commit comments