Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/brief.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ pub fn render(
_ => snake(&e.name),
};
let asyncness = if e.is_async { " (async)" } else { "" };
let _ = writeln!(
out,
"- `{}` {}{asyncness} → `{module}::{rust_name}`",
e.name, e.kind
);
// `done` skips default exports, so name what it accepts
// instead of an item no Rust module can hold.
let target = if e.kind == "default" {
"no Rust item of its own; name the one that replaces it with `--map default=<path>`, or `--map default=-`".to_owned()
} else {
format!("`{module}::{rust_name}`")
};
let _ = writeln!(out, "- `{}` {}{asyncness} → {target}", e.name, e.kind);
}
}

Expand Down
27 changes: 27 additions & 0 deletions tests/porting_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,3 +1893,30 @@ args = ["signal"]
text(&out)
);
}

#[test]
fn a_default_export_is_briefed_without_an_invented_rust_item() {
let f = fixture();
let plugin = "src/ts/app/src/plugin.ts";
f.write(
plugin,
"export const PLUGIN_ID = \"x\";\nexport default { id: PLUGIN_ID };\n",
);

let brief = text(&f.port(&["brief", plugin]));

// The named export maps to a Rust item; the default export names the
// --map forms `done` accepts instead of `app::plugin::default`.
let exports: Vec<&str> = brief
.lines()
.filter(|line| line.starts_with("- `PLUGIN_ID`") || line.starts_with("- `default`"))
.collect();
assert_eq!(
exports,
[
"- `PLUGIN_ID` const → `app::plugin::PLUGIN_ID`",
"- `default` default → no Rust item of its own; name the one that replaces it with `--map default=<path>`, or `--map default=-`",
],
"{brief}"
);
}