Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build script error behavior #110

Open
calebcartwright opened this issue Jul 9, 2020 · 0 comments · May be fixed by #142
Open

Update build script error behavior #110

calebcartwright opened this issue Jul 9, 2020 · 0 comments · May be fixed by #142
Labels
good first issue Good for newcomers help wanted Pull Requests/Assistance welcomed!

Comments

@calebcartwright
Copy link
Member

Currently, the build script is used to perform local setup when rusty-hook is leveraged as a dev dependency to simplify and automated the hook setup process.

Our build script always exits with 0 even when the initialization process fails with an accompanying error message printed.

rusty-hook/build.rs

Lines 14 to 25 in b90df24

if let Err(err) = rusty_hook::init_directory(
nias::get_command_runner(),
nias::get_file_writer(),
nias::get_file_existence_checker(),
Some(&target_directory),
) {
println!(
"Fatal error encountered during initialization. Details: {}",
err
);
};
exit(0);

However, cargo doesn't display any output from build scripts unless invoked with the -vv flag which shouldn't be a requirement (it is by definition very vebose 😉).

I'm not really sure why we did it this way, probably an attempt to avoid any failures during the initial cargo test run, but it's problematic because the initialization will just silently fail in the event of any init issues which makes for a poor user experience (refs #109).

We should just have the build script exit properly when initialization fails so that the output is displayed. Users can always remove rusty-hook from their dev-deps if it becomes a blocking issue for them

This could be fixed with something as simple as the following:

    if let Err(err) = rusty_hook::init_directory(
        nias::get_command_runner(),
        nias::get_file_writer(),
        nias::get_file_existence_checker(),
        Some(&target_directory),
    ) {
        eprintln!(
            "\n[rusty-hook]: Fatal error encountered during initialization. Details: {}\n",
            err
        );
        exit(1);
    };
    exit(0);
@calebcartwright calebcartwright added help wanted Pull Requests/Assistance welcomed! good first issue Good for newcomers labels Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Pull Requests/Assistance welcomed!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant