Skip to content

fix(install): better json editing #26450

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 5 commits into from
Oct 21, 2024

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Oct 21, 2024

  1. Respects the formatting of the file (ex. keeps four space indents or tabs).
  2. Handles editing of comments.
  3. Handles trailing commas.
  4. Code is easier to maintain.

Comment on lines +82 to +83
fn contents(&self) -> String {
self.cst.to_string()
Copy link
Member

Choose a reason for hiding this comment

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

Does it need to be accessed more than one time? If not, consider making it consume self to better communicate that?

Copy link
Member Author

Choose a reason for hiding this comment

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

self.path is still used after this.

let deps_prop = self.root_object.get("dependencies");
let dev_deps_prop = self.root_object.get("devDependencies");

let dependencies = if dev {
Copy link
Member

Choose a reason for hiding this comment

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

Will this still remove the entry from the other "dependencies" when inserting it?

Ie. will deno install npm:foo and then deno install --dev npm:foo leave only a single entry and not entry in both dependencies and devDependencies?

path: PathBuf,
modified: bool,
}
if let Some(other) = other_dependencies {
Copy link
Member

Choose a reason for hiding this comment

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

Oh I see now that it will 👍

@dsherret dsherret merged commit 39fb550 into denoland:main Oct 21, 2024
17 checks passed
@dsherret dsherret deleted the fix_improve_json_manipulation branch October 21, 2024 18:17
bartlomieju pushed a commit that referenced this pull request Oct 25, 2024
1. Respects the formatting of the file (ex. keeps four space indents or
tabs).
2. Handles editing of comments.
3. Handles trailing commas.
4. Code is easier to maintain.
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.

3 participants