Merge pull request #576 from boblehest/check_cwd_for_config

Check if the CWD contains a config (previously it only checked parents)
This commit is contained in:
Nick Cameron 2015-11-09 17:05:48 -05:00
commit 5346daf541

View File

@ -54,14 +54,15 @@ fn lookup_project_file(input_file: &Path) -> io::Result<PathBuf> {
// current = try!(fs::canonicalize(current));
loop {
// If the current directory has no parent, we're done searching.
if !current.pop() {
return Err(io::Error::new(io::ErrorKind::NotFound, "Config not found"));
}
let config_file = current.join("rustfmt.toml");
if fs::metadata(&config_file).is_ok() {
return Ok(config_file);
}
// If the current directory has no parent, we're done searching.
if !current.pop() {
return Err(io::Error::new(io::ErrorKind::NotFound, "Config not found"));
}
}
}