mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-14 07:45:04 +00:00
Merge pull request #3678 from rtfeldman/no-canonicalize
Don't use fs::canonicalize in CLI
This commit is contained in:
commit
e09739caec
1 changed files with 21 additions and 39 deletions
|
@ -336,31 +336,22 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
||||||
let path = Path::new(filename);
|
let path = Path::new(filename);
|
||||||
|
|
||||||
// Spawn the root task
|
// Spawn the root task
|
||||||
let path = path.canonicalize().unwrap_or_else(|err| {
|
if !path.exists() {
|
||||||
use io::ErrorKind::*;
|
let path_string = path.to_string_lossy();
|
||||||
|
|
||||||
match err.kind() {
|
// TODO these should use roc_reporting to display nicer error messages.
|
||||||
NotFound => {
|
match matches.value_source(ROC_FILE) {
|
||||||
let path_string = path.to_string_lossy();
|
Some(ValueSource::DefaultValue) => {
|
||||||
|
eprintln!(
|
||||||
// TODO these should use roc_reporting to display nicer error messages.
|
"\nNo `.roc` file was specified, and the current directory does not contain a {} file to use as a default.\n\nYou can run `roc help` for more information on how to provide a .roc file.\n",
|
||||||
match matches.value_source(ROC_FILE) {
|
DEFAULT_ROC_FILENAME
|
||||||
Some(ValueSource::DefaultValue) => {
|
)
|
||||||
eprintln!(
|
|
||||||
"\nNo `.roc` file was specified, and the current directory does not contain a {} file to use as a default.\n\nYou can run `roc help` for more information on how to provide a .roc file.\n",
|
|
||||||
DEFAULT_ROC_FILENAME
|
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => eprintln!("\nThis file was not found: {}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n", path_string),
|
|
||||||
}
|
|
||||||
|
|
||||||
process::exit(1);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
todo!("TODO Gracefully handle opening {:?} - {:?}", path, err);
|
|
||||||
}
|
}
|
||||||
|
_ => eprintln!("\nThis file was not found: {}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n", path_string),
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
let arena = &arena;
|
let arena = &arena;
|
||||||
let target = &triple;
|
let target = &triple;
|
||||||
|
@ -372,7 +363,7 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
||||||
|
|
||||||
let loaded = roc_load::load_and_monomorphize(
|
let loaded = roc_load::load_and_monomorphize(
|
||||||
arena,
|
arena,
|
||||||
path,
|
path.to_path_buf(),
|
||||||
subs_by_module,
|
subs_by_module,
|
||||||
target_info,
|
target_info,
|
||||||
// TODO: expose this from CLI?
|
// TODO: expose this from CLI?
|
||||||
|
@ -507,15 +498,11 @@ pub fn build(
|
||||||
let path = Path::new(filename);
|
let path = Path::new(filename);
|
||||||
|
|
||||||
// Spawn the root task
|
// Spawn the root task
|
||||||
let path = path.canonicalize().unwrap_or_else(|err| {
|
if !path.exists() {
|
||||||
use io::ErrorKind::*;
|
let path_string = path.to_string_lossy();
|
||||||
|
|
||||||
match err.kind() {
|
// TODO these should use roc_reporting to display nicer error messages.
|
||||||
NotFound => {
|
match matches.value_source(ROC_FILE) {
|
||||||
let path_string = path.to_string_lossy();
|
|
||||||
|
|
||||||
// TODO these should use roc_reporting to display nicer error messages.
|
|
||||||
match matches.value_source(ROC_FILE) {
|
|
||||||
Some(ValueSource::DefaultValue) => {
|
Some(ValueSource::DefaultValue) => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"\nNo `.roc` file was specified, and the current directory does not contain a {} file to use as a default.\n\nYou can run `roc help` for more information on how to provide a .roc file.\n",
|
"\nNo `.roc` file was specified, and the current directory does not contain a {} file to use as a default.\n\nYou can run `roc help` for more information on how to provide a .roc file.\n",
|
||||||
|
@ -525,19 +512,14 @@ pub fn build(
|
||||||
_ => eprintln!("\nThis file was not found: {}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n", path_string),
|
_ => eprintln!("\nThis file was not found: {}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n", path_string),
|
||||||
}
|
}
|
||||||
|
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
todo!("TODO Gracefully handle opening {:?} - {:?}", path, err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let target_valgrind = matches.is_present(FLAG_VALGRIND);
|
let target_valgrind = matches.is_present(FLAG_VALGRIND);
|
||||||
let res_binary_path = build_file(
|
let res_binary_path = build_file(
|
||||||
&arena,
|
&arena,
|
||||||
&triple,
|
&triple,
|
||||||
path,
|
path.to_path_buf(),
|
||||||
opt_level,
|
opt_level,
|
||||||
emit_debug_info,
|
emit_debug_info,
|
||||||
emit_timings,
|
emit_timings,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue