这是indexloc提供的服务,不要输入任何密码
Skip to content

#1283 - Fixed json5 support #1472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ require (
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
muzzammil.xyz/jsonc v1.0.0 // indirect
)
2 changes: 2 additions & 0 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
muzzammil.xyz/jsonc v1.0.0 h1:B6kaT3wHueZ87mPz3q1nFuM1BlL32IG0wcq0/uOsQ18=
muzzammil.xyz/jsonc v1.0.0/go.mod h1:rFv8tUUKe+QLh7v02BhfxXEf4ZHhYD7unR93HL/1Uvo=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
11 changes: 9 additions & 2 deletions cli/internal/fs/testdata/turbo.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// mocked test comment
{
"pipeline": {
"build": {
// mocked test comment
"dependsOn": [
// mocked test comment
"^build"
],
"outputs": [
"dist/**",
".next/**"
],
"outputMode": "new-only"
},
}, // mocked test comment
"lint": {
"outputs": [],
"dependsOn": [
Expand All @@ -22,15 +25,19 @@
"cache": false,
"outputMode": "full"
},
/* mocked test comment */
"publish": {
"outputs": [
"dist/**"
],
"inputs": [
/*
mocked test comment
*/
"build/**/*"
],
"dependsOn": [
"^publish",
/* mocked test comment */"^publish",
"build",
"admin#lint"
],
Expand Down
11 changes: 7 additions & 4 deletions cli/internal/fs/turbo_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package fs
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"strings"

"github.com/vercel/turborepo/cli/internal/util"
"github.com/yosuke-furukawa/json5/encoding/json5"
"muzzammil.xyz/jsonc"
)

// TurboJSON is the root turborepo configuration
Expand Down Expand Up @@ -57,10 +58,12 @@ func ReadTurboJSON(path AbsolutePath) (*TurboJSON, error) {
if err != nil {
return nil, err
}

var turboJSON *TurboJSON
decoder := json5.NewDecoder(file)
err = decoder.Decode(&turboJSON)
data, err := ioutil.ReadAll(file)
if err != nil {
return nil, err
}
err = jsonc.Unmarshal(data, &turboJSON)
if err != nil {
println("error unmarshalling", err.Error())
return nil, err
Expand Down