mirror of
https://github.com/esp-rs/espup.git
synced 2025-09-28 05:10:44 +00:00
feat: ✨ Check if the provided export-file is a file path
This commit is contained in:
parent
829820f4c8
commit
6aae03d230
@ -84,4 +84,10 @@ pub enum Error {
|
||||
emoji::ERROR
|
||||
)]
|
||||
FailedToRemoveFile(String),
|
||||
#[diagnostic(code(espup::wrong_export_file))]
|
||||
#[error(
|
||||
"{} Wrong export file destination: '{0}'. Please, use an absolte or releative path (including the file and its extension).",
|
||||
emoji::ERROR
|
||||
)]
|
||||
WrongExportFile(String),
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use log::{debug, info, warn};
|
||||
use miette::Result;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
fs::{remove_dir_all, remove_file, File},
|
||||
fs::{metadata, remove_dir_all, remove_file, File},
|
||||
io::Write,
|
||||
path::PathBuf,
|
||||
};
|
||||
@ -428,6 +428,10 @@ fn clear_dist_folder() -> Result<(), Error> {
|
||||
/// Returns the absolute path to the export file, uses the DEFAULT_EXPORT_FILE if no arg is provided.
|
||||
fn get_export_file(export_file: Option<PathBuf>) -> Result<PathBuf, Error> {
|
||||
if let Some(export_file) = export_file {
|
||||
let metadata = export_file.metadata()?;
|
||||
if !metadata.is_file() {
|
||||
return Err(Error::WrongExportFile(export_file.display().to_string()));
|
||||
}
|
||||
if export_file.is_absolute() {
|
||||
Ok(export_file)
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user