diff --git a/cli/go.mod b/cli/go.mod index 9727374e828ec..dac30e59b7e86 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -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 ) diff --git a/cli/go.sum b/cli/go.sum index b21f4727ea8e1..29d6e11156d43 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -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= diff --git a/cli/internal/fs/testdata/turbo.json b/cli/internal/fs/testdata/turbo.json index 2fddfbba55baf..9a3e877bcea64 100644 --- a/cli/internal/fs/testdata/turbo.json +++ b/cli/internal/fs/testdata/turbo.json @@ -1,7 +1,10 @@ +// mocked test comment { "pipeline": { "build": { + // mocked test comment "dependsOn": [ + // mocked test comment "^build" ], "outputs": [ @@ -9,7 +12,7 @@ ".next/**" ], "outputMode": "new-only" - }, + }, // mocked test comment "lint": { "outputs": [], "dependsOn": [ @@ -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" ], diff --git a/cli/internal/fs/turbo_json.go b/cli/internal/fs/turbo_json.go index 03ec595dc9149..b45635e87c96f 100644 --- a/cli/internal/fs/turbo_json.go +++ b/cli/internal/fs/turbo_json.go @@ -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 @@ -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