MCPcopy Create free account
hub / github.com/JamieMason/syncpack / copy_expected_specifier_json

Function copy_expected_specifier_json

src/disk.rs:683–704  ·  view source on GitHub ↗

Apply an instance's `expected_specifier` to the package.json. Dispatches over the dependency type's `Strategy`. Marks the file dirty only when the stored value actually changed.

(file: &mut File<JsonValue>, instance: &Instance)

Source from the content-addressed store, hash-verified

681/// over the dependency type's `Strategy`. Marks the file dirty only when the
682/// stored value actually changed.
683pub fn copy_expected_specifier_json(file: &mut File<JsonValue>, instance: &Instance) {
684 let path_to_prop_str = &instance.descriptor.dependency_type.path.as_str();
685 let raw_specifier = instance.expected_specifier.borrow().as_ref().unwrap().get_raw().to_string();
686 match instance.descriptor.dependency_type.strategy {
687 Strategy::NameAndVersionProps => {
688 set_prop(file, path_to_prop_str, JsonValue::String(raw_specifier));
689 }
690 Strategy::NamedVersionString => {
691 let full_value = format!("{}@{}", instance.descriptor.name, raw_specifier);
692 set_prop(file, path_to_prop_str, JsonValue::String(full_value));
693 }
694 Strategy::UnnamedVersionString => {
695 set_prop(file, path_to_prop_str, JsonValue::String(raw_specifier));
696 }
697 Strategy::VersionsByName => {
698 set_nested_prop(file, path_to_prop_str, &instance.descriptor.name, JsonValue::String(raw_specifier));
699 }
700 Strategy::InvalidConfig => {
701 unreachable!("unrecognised strategy");
702 }
703 };
704}
705
706/// Eagerly convert the parsed yaml into an owned `serde_json::Value`. No
707/// caching — every call allocates a fresh Value. Caller is expected to

Calls 4

set_propFunction · 0.85
set_nested_propFunction · 0.85
get_rawMethod · 0.80
unwrapMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…