Skip to content

Commit 17865d4

Browse files
committed
Show full source path if relative path is empty
1 parent 2c0b09b commit 17865d4

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

src/main.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -118,34 +118,29 @@ fn main() {
118118
std::process::exit(-1);
119119
});
120120

121+
let canonical_current_dir = std::fs::canonicalize(std::env::current_dir().unwrap()).unwrap();
122+
let relative_source = source
123+
.strip_prefix(&canonical_current_dir)
124+
.unwrap_or(&source);
125+
let relative_source = if relative_source.components().count() == 0 {
126+
&canonical_current_dir
127+
} else {
128+
relative_source
129+
};
121130
let count = if source.is_dir() {
122131
println!(
123132
"{} {}counting contents of {}…",
124133
style("[1/4]").bold().dim(),
125134
Emoji("🔍 ", ""),
126-
style(
127-
&source
128-
.strip_prefix(std::fs::canonicalize(std::env::current_dir().unwrap()).unwrap())
129-
.unwrap_or(&source)
130-
.display()
131-
)
132-
.blue()
133-
.bright()
135+
style(relative_source.display()).blue().bright()
134136
);
135137
WalkDir::new(&source).skip_hidden(false).into_iter().count() as u64 - 1
136138
} else {
137139
println!(
138140
"{} {}checking {}…",
139141
style("[1/4]").bold().dim(),
140142
Emoji("🔍 ", ""),
141-
style(
142-
&source
143-
.strip_prefix(std::fs::canonicalize(std::env::current_dir().unwrap()).unwrap())
144-
.unwrap_or(&source)
145-
.display()
146-
)
147-
.blue()
148-
.bright()
143+
style(relative_source.display()).blue().bright()
149144
);
150145
1
151146
};
@@ -156,7 +151,7 @@ fn main() {
156151
Emoji("📃 ", ""),
157152
style(
158153
&output
159-
.strip_prefix(std::fs::canonicalize(std::env::current_dir().unwrap()).unwrap())
154+
.strip_prefix(&canonical_current_dir)
160155
.unwrap_or(&output)
161156
.display()
162157
)
@@ -177,7 +172,7 @@ fn main() {
177172
.unwrap_or_else(|error| {
178173
println!(
179174
" {}{} {}",
180-
Emoji("⚠️ ", ""),
175+
Emoji(" ", ""),
181176
style("failed to set subsystem for runner:").yellow(),
182177
style(error).yellow()
183178
);
@@ -206,7 +201,7 @@ fn main() {
206201
.unwrap_or_else(|error| {
207202
println!(
208203
" {}{} {}",
209-
Emoji("⚠️ ", ""),
204+
Emoji(" ", ""),
210205
style("failed to copy resources to runner:").yellow(),
211206
style(error).yellow()
212207
);
@@ -242,7 +237,11 @@ fn main() {
242237
},
243238
|message| {
244239
bar_progress.inc(1);
245-
bar_progress.println(format!(" {}{}", Emoji("⚠️ ", ""), style(message).red()));
240+
bar_progress.println(format!(
241+
" {}{}",
242+
Emoji("❗ ", ""),
243+
style(message).red()
244+
));
246245
},
247246
|message| {
248247
bar_progress.set_message(format!("{}", style(message).blue().bright()));
@@ -314,7 +313,7 @@ fn main() {
314313
set_permissions(&output, PermissionsExt::from_mode(mode | 0o111)).unwrap_or_else(|e| {
315314
eprintln!(
316315
" {} failed to set permissions for {}: {}",
317-
Emoji("⚠️ ", ""),
316+
Emoji(" ", ""),
318317
output.display(),
319318
e
320319
)

0 commit comments

Comments
 (0)