Skip to content

Commit 0709e66

Browse files
committed
Ensure the output directory exists before we start watching it
Fixes #27
1 parent fd46842 commit 0709e66

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

xtask/src/main.rs

+7
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ fn do_assets_watch(
111111
) -> Result<(), AssetsWatchError> {
112112
use assets_watch_error::*;
113113

114+
// The directory needs to exist before we can watch it.
115+
std::fs::create_dir_all(&asset_root)
116+
.context(AssetDirectoryCreateSnafu { path: &asset_root })?;
117+
114118
let (tx, rx) = mpsc::channel();
115119

116120
let mut watcher = notify::recommended_watcher(move |evt: notify::Result<notify::Event>| {
@@ -142,6 +146,9 @@ fn do_assets_watch(
142146
#[derive(Debug, Snafu)]
143147
#[snafu(module)]
144148
enum AssetsWatchError {
149+
#[snafu(display("Could not create the asset directory"))]
150+
AssetDirectoryCreate { source: io::Error, path: PathBuf },
151+
145152
#[snafu(display("Could not create the filesystem watcher"))]
146153
WatcherCreate { source: notify::Error },
147154

0 commit comments

Comments
 (0)