Skip to content

Commit 49bab23

Browse files
Merge pull request #212 from techieyann/deterministic-plug-order
Make `wac plug` output deterministic
2 parents d833531 + 1171a94 commit 49bab23

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/commands/plug.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ impl PlugCommand {
152152
let socket = Package::from_bytes("socket", None, socket, graph.types_mut())?;
153153
let socket = graph.register_package(socket)?;
154154

155-
// Collect the plugs by their names
156-
let mut plugs_by_name = std::collections::HashMap::<_, Vec<_>>::new();
155+
// Collect the plugs by their names.
156+
// An insertion-ordered map is used so that plugs are registered and
157+
// instantiated in command-line order, which makes the encoded output
158+
// deterministic; iterating a `HashMap` here made the emitted component
159+
// order vary between runs on identical inputs.
160+
let mut plugs_by_name = indexmap::IndexMap::<_, Vec<_>>::new();
157161
for plug in self.plugs.iter() {
158162
let name = match plug {
159163
#[cfg(feature = "registry")]

0 commit comments

Comments
 (0)