Merge pull request #5408 from Maldus512/issue-5394

Fixes issue #5394
This commit is contained in:
Folkert de Vries 2023-05-15 15:09:01 +02:00 committed by GitHub
commit ebc822d3c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -406,17 +406,22 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
// Spawn the root task
if !path.exists() {
let path_string = path.to_string_lossy();
let current_dir = env::current_dir().unwrap();
let expected_file_path = current_dir.join(filename);
let current_dir_string = current_dir.display();
let expected_file_path_string = expected_file_path.display();
// TODO these should use roc_reporting to display nicer error messages.
match matches.value_source(ROC_FILE) {
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",
"\nThe 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",
current_dir_string,
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),
_ => eprintln!("\nThis file was not found: {}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n", expected_file_path_string),
}
process::exit(1);
@ -541,17 +546,22 @@ pub fn build(
// Spawn the root task
if !path.exists() {
let path_string = path.to_string_lossy();
let current_dir = env::current_dir().unwrap();
let expected_file_path = current_dir.join(filename);
let current_dir_string = current_dir.display();
let expected_file_path_string = expected_file_path.display();
// TODO these should use roc_reporting to display nicer error messages.
match matches.value_source(ROC_FILE) {
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",
"\nThe 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",
current_dir_string,
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),
_ => eprintln!("\nThis file was not found: {}\n\nYou can run `roc help` for more information on how to provide a .roc file.\n", expected_file_path_string),
}
process::exit(1);