-
Notifications
You must be signed in to change notification settings - Fork 337
Fix wrangler config
for systems with non-unix EOL
#399
Conversation
email: email.to_string(), | ||
api_key: api_key.to_string(), | ||
}; | ||
pub fn global_config(email: String, api_key: String) -> Result<(), failure::Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while I was in here, I fixed the ownership semantics of global_config to remove a useless string copy.
@@ -153,11 +153,13 @@ fn run() -> Result<(), failure::Error> { | |||
|
|||
if let Some(_matches) = matches.subcommand_matches("config") { | |||
println!("Enter email: "); | |||
let email: String = read!("{}\n"); | |||
let mut email: String = read!("{}\n"); | |||
email.truncate(email.trim_end().len()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the truncate dance here is to avoid allocating an extra string, and to keep email as an owned String instead of a string slice
let fake_home_dir = env::current_dir() | ||
.expect("could not retrieve cwd") | ||
.join(".it_generates_the_config"); | ||
.join(format!(".it_generates_the_config_{}", random_chars(5))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because cargo test
is multithreaded, I had to add this random_char thing to the end of the home directory name to keep the threads from deleting each other's home dir. We should probably enforce this for all tests that create directories in the future.
0d84edc
to
b15e45d
Compare
Also: wanted review on the actual PR title and message content, trying out formatting these such that they work well when copy-pasted into a changelog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, great work
println!("Enter api key: "); | ||
let api_key: String = read!("{}\n"); | ||
let mut api_key: String = read!("{}\n"); | ||
api_key.truncate(api_key.trim_end().len()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😻
f25e36f
to
6b1c2cc
Compare
72dc218
to
3269f4c
Compare
wrangler config
was not properly truncating whitespace from the end of user input, resulting in a panic when trying to usewrangler publish
as wrangler would try to create an HTTP header with invalid characters. Now, wrangler will properly truncate extra whitespace (including\r
) from the end of input towrangler config
Fixes #389