Skip to content

Commit

Permalink
fix: recognize project.yml update
Browse files Browse the repository at this point in the history
  • Loading branch information
kkharji committed Apr 18, 2022
1 parent a201b2e commit 9b53d44
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
7 changes: 6 additions & 1 deletion src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ impl State {
match self.workspaces.get_mut(root) {
Some(workspace) => workspace.add_client(pid),
None => {
let workspace = Workspace::new_with_client(&root, pid).await?;
let workspace = {
let root: &str = &root;
let mut ws = Workspace::new(&root).await?;
ws.add_client(pid);
ws
};

tracing::info!("Managing [{}] {:?}", workspace.project.name(), root);

Expand Down
13 changes: 2 additions & 11 deletions src/state/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ impl Workspace {
})
}

pub async fn new_with_client(root: &str, pid: i32) -> Result<Self> {
let mut ws = Workspace::new(&root).await?;
ws.add_client(pid);
Ok(ws)
}

pub fn update_clients(&mut self) {
let name = self.project.name();
self.clients
Expand Down Expand Up @@ -104,11 +98,8 @@ impl Workspace {
_event: notify::EventKind,
) -> Result<()> {
if crate::xcodegen::is_workspace(self) {
let is_config_file = path.file_name().unwrap().eq("project");
// FIXME: should've been true
tracing::debug!("is_config_file: {is_config_file}");

self.update_xcodeproj(is_config_file).await?;
self.update_xcodeproj(path.file_name().unwrap().eq("project.yml"))
.await?;
}

xcode::ensure_server_config_file(&self.root).await?;
Expand Down
8 changes: 7 additions & 1 deletion src/xcodegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ pub async fn generate<P: AsRef<Path> + Debug>(root: P) -> Result<Vec<String>> {
.expect("Failed to run xcodeGen.");

if output.status.code().unwrap().ne(&0) {
anyhow::bail!("{:#?}", output.stderr)
anyhow::bail!(
"{:#?}",
String::from_utf8(output.stderr)?
.split("\n")
.map(|s| s.to_string())
.collect::<Vec<String>>()
)
} else {
Ok(String::from_utf8(output.stdout)?
.split("\n")
Expand Down

0 comments on commit 9b53d44

Please sign in to comment.