mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
uses the word 'folder' consistently
This commit is contained in:
parent
8bafbf3beb
commit
797605cd72
1 changed files with 27 additions and 24 deletions
|
@ -26,39 +26,42 @@ use roc_parse::{
|
||||||
use roc_region::all::{Loc, Region};
|
use roc_region::all::{Loc, Region};
|
||||||
|
|
||||||
fn flatten_folders(files: std::vec::Vec<PathBuf>) -> std::vec::Vec<PathBuf> {
|
fn flatten_folders(files: std::vec::Vec<PathBuf>) -> std::vec::Vec<PathBuf> {
|
||||||
files.into_iter().flat_map(|file| {
|
files
|
||||||
if file.is_dir() {
|
.into_iter()
|
||||||
match file.read_dir() {
|
.flat_map(|file| {
|
||||||
Ok(directory) => directory
|
if file.is_dir() {
|
||||||
.flat_map(|result| match result {
|
match file.read_dir() {
|
||||||
Ok(file) => {
|
Ok(folder) => folder
|
||||||
let path = file.path();
|
.flat_map(|result| match result {
|
||||||
|
Ok(file) => {
|
||||||
|
let path = file.path();
|
||||||
|
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
flatten_folders(vec![path])
|
flatten_folders(vec![path])
|
||||||
} else if path.ends_with(".roc") {
|
} else if path.ends_with(".roc") {
|
||||||
vec![path]
|
vec![path]
|
||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
Err(error) => internal_error!(
|
||||||
Err(error) => internal_error!(
|
|
||||||
"There was an error while trying to read a file from a folder: {:?}",
|
"There was an error while trying to read a file from a folder: {:?}",
|
||||||
error
|
error
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
internal_error!(
|
internal_error!(
|
||||||
"There was an error while trying to read the contents of a directory: {:?}",
|
"There was an error while trying to read the contents of a folder: {:?}",
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
vec![file]
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
vec![file]
|
.collect()
|
||||||
}
|
|
||||||
}).collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format(files: std::vec::Vec<PathBuf>, mode: FormatMode) -> Result<(), String> {
|
pub fn format(files: std::vec::Vec<PathBuf>, mode: FormatMode) -> Result<(), String> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue