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

Turbo Config refactor #1739

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 2 commits into from
Aug 23, 2022
Merged

Turbo Config refactor #1739

merged 2 commits into from
Aug 23, 2022

Conversation

mehulkar
Copy link
Contributor

I'm starting to work on updating where env vars are read from. As I started writing a test case,, I noticed that our unit test is against a function that we don't actually use, so I've updated the test case here.

@mehulkar mehulkar requested a review from a team as a code owner August 23, 2022 00:33
@vercel
Copy link

vercel bot commented Aug 23, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
turbo-site ✅ Ready (Inspect) Visit Preview Aug 23, 2022 at 6:24PM (UTC)

// ReadTurboJSON reads turbo.json in to a struct
func ReadTurboJSON(path AbsolutePath) (*TurboJSON, error) {
// readTurboJSON reads the CONFIG_FILE in to a struct
func readTurboJSON(path AbsolutePath) (*TurboJSON, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now a private function, because it is only used internally here

// ReadTurboConfig toggles between reading from package.json or turbo.json to support early adopters.
const CONFIG_FILE = "turbo.json"

// ReadTurboConfig toggles between reading from package.json or the CONFIG_FILE to support early adopters.
func ReadTurboConfig(rootPath AbsolutePath, rootPackageJSON *PackageJSON) (*TurboJSON, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to remove rootPackageJSON and read package.json internally, but the parent function is also reading it, so we'd duplicate the read. If we only needed to read package.json when turbo.json was missing, I think it would be a good tradeoff, but we are always reading package.json so we can log when turbo key exists and should be removed.

I would like to remove it, so we don't have to reproduce it a package.json for every test case we write and pass it in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always need to read every package.json anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was hoping to inline, but only if the double read would only apply in the fallback scenario (i.e. not very often). But since it's always used in this function, I can't make that tradeoff

// ReadTurboConfig toggles between reading from package.json or turbo.json to support early adopters.
const CONFIG_FILE = "turbo.json"

// ReadTurboConfig toggles between reading from package.json or the CONFIG_FILE to support early adopters.
func ReadTurboConfig(rootPath AbsolutePath, rootPackageJSON *PackageJSON) (*TurboJSON, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always need to read every package.json anyways.

@mehulkar mehulkar merged commit 1064e42 into main Aug 23, 2022
@mehulkar mehulkar deleted the mk/turbo-json branch August 23, 2022 18:37
nathanhammond added a commit to nathanhammond/turbo that referenced this pull request Aug 31, 2022
kodiakhq bot pushed a commit that referenced this pull request Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants