Skip to content

Commit fad73bf

Browse files
committed
Print the workspace
1 parent fb2f97e commit fad73bf

File tree

1 file changed

+37
-14
lines changed
  • projects/publish-rs/src/commands

1 file changed

+37
-14
lines changed
+37-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1+
use crate::bindings::GithubTarget;
12
use crate::{
2-
GithubError, bindings,
3-
bindings::{Guest, export},
4-
};
5-
use std::{
6-
path::{Path, PathBuf},
3+
bindings, bindings::{export, Guest},
4+
GithubError,
75
};
8-
use std::env::VarError;
9-
use crate::bindings::GithubTarget;
6+
use std::collections::HashMap;
7+
use std::path::Path;
108

119
pub struct RunningContext {}
1210

1311
impl Guest for RunningContext {
1412
fn run_with_config(config: String, target: GithubTarget) -> Result<(), GithubError> {
1513
match std::env::var("INPUT_CONFIG") {
1614
Ok(o) => {o}
17-
Err(_) => {
18-
println!("MissingConfig {}")
15+
Err(e) => {
16+
println!("MissingConfig {}", e);
17+
return Ok(())
1918
}
2019
}
2120

@@ -30,17 +29,41 @@ impl RunningContext {
3029
async fn run(&self, config: String) -> Result<(), GithubError> {
3130
match std::env::var("GITHUB_WORKSPACE") {
3231
Ok(s) => {
33-
let config = PathBuf::from(s).join(&config);
34-
let txt = std::fs::read_to_string(config);
35-
println!("Config: {:?}", txt)
32+
println!("GITHUB_WORKSPACE");
33+
read_dir(&s)
34+
}
35+
Err(e) => {
36+
println!("{}", e)
37+
}
38+
}
39+
match std::env::var("RUNNER_WORKSPACE") {
40+
Ok(s) => {
41+
println!("RUNNER_WORKSPACE");
42+
read_dir(&s)
3643
}
3744
Err(e) => {
3845
println!("{}", e)
3946
}
4047
}
41-
println!("Env: {:#?}", std::env::vars());
48+
let mut envs = HashMap::new();
49+
for (key, value) in std::env::vars() {
50+
envs.insert(key, value);
51+
}
52+
println!("Env: {:#?}", envs);
4253
Ok(())
4354
}
4455
}
45-
56+
fn read_dir(dir_path: &str) {
57+
let path = Path::new(dir_path);
58+
if let Ok(dir_entries) = std::fs::read_dir(path) {
59+
for entry in dir_entries {
60+
if let Ok(entry) = entry {
61+
let file_name = entry.file_name();
62+
println!("{}", file_name.to_string_lossy());
63+
}
64+
}
65+
} else {
66+
println!("Error reading directory: {}", dir_path);
67+
}
68+
}
4669
export!(RunningContext with_types_in bindings);

0 commit comments

Comments
 (0)