Skip to content

Commit

Permalink
🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
volllly committed Jun 30, 2022
1 parent ae4aded commit 331d4ff
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 126 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v0.4.1] - 2022-06-30

### Fixed

- Wildcard "*" in install command not working
- Defaults and global values in `dot.(yaml|toml|json)` files not working correctly

## [v0.4.0] - 2022-06-29

### Added
Expand Down Expand Up @@ -89,7 +96,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Dotfile linking
- Error handling

[Unreleased]: https://github.com/volllly/rotz/compare/v0.4.0...HEAD
[Unreleased]: https://github.com/volllly/rotz/compare/v0.4.1...HEAD
[v0.4.1]: https://github.com/volllly/rotz/releases/tag/v0.3.2
[v0.4.0]: https://github.com/volllly/rotz/releases/tag/v0.3.2
[v0.3.2]: https://github.com/volllly/rotz/releases/tag/v0.3.2
[v0.3.1]: https://github.com/volllly/rotz/releases/tag/v0.3.1
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rotz"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
authors = [ "Paul Volavsek <paul.volavsek@gmail.com>" ]
license = "MIT"
Expand Down
80 changes: 39 additions & 41 deletions src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,52 +94,50 @@ impl Install {
}
}

if !installs.cmd.is_empty() {
println!("{}Installing {}{}\n", Attribute::Bold, entry.0.as_str().blue(), Attribute::Reset);

let inner_cmd = HANDLEBARS
println!("{}Installing {}{}\n", Attribute::Bold, entry.0.as_str().blue(), Attribute::Reset);

let inner_cmd = HANDLEBARS
.render_template(
&installs.cmd.to_string(),
&json!({
"name": entry.0
}),
)
.map_err(|err| Error::RenderingTemplate(entry.0.to_string(), err))?;

let cmd = if let Some(shell_command) = self.config.shell_command.as_ref() {
HANDLEBARS
.render_template(
&installs.cmd.to_string(),
shell_command,
&json!({
"name": entry.0
"name": entry.0,
"cmd": &inner_cmd
}),
)
.map_err(|err| Error::RenderingTemplate(entry.0.to_string(), err))?;

let cmd = if let Some(shell_command) = self.config.shell_command.as_ref() {
HANDLEBARS
.render_template(
shell_command,
&json!({
"name": entry.0,
"cmd": &inner_cmd
}),
)
.map_err(|err| Error::RenderingTemplate(entry.0.to_string(), err))?
} else {
inner_cmd.clone()
};

let cmd = shellwords::split(&cmd).map_err(|err| Error::ParsingInstallCommand(entry.0.to_string(), err))?;

println!("{}{}{}\n", Attribute::Italic, inner_cmd, Attribute::Reset);

if !globals.dry_run {
let output = process::Command::new(&cmd[0])
.args(&cmd[1..])
.stdin(process::Stdio::null())
.stdout(process::Stdio::inherit())
.stderr(process::Stdio::inherit())
.output()
.map_err(|e| Error::InstallSpawn(entry.0.to_string(), e))?;

if !install_command.continue_on_error && !output.status.success() {
return Error::InstallExecute(entry.0.to_string(), output.status.code()).error();
}
.map_err(|err| Error::RenderingTemplate(entry.0.to_string(), err))?
} else {
inner_cmd.clone()
};

let cmd = shellwords::split(&cmd).map_err(|err| Error::ParsingInstallCommand(entry.0.to_string(), err))?;

println!("{}{}{}\n", Attribute::Italic, inner_cmd, Attribute::Reset);

if !globals.dry_run {
let output = process::Command::new(&cmd[0])
.args(&cmd[1..])
.stdin(process::Stdio::null())
.stdout(process::Stdio::inherit())
.stderr(process::Stdio::inherit())
.output()
.map_err(|e| Error::InstallSpawn(entry.0.to_string(), e))?;

if !install_command.continue_on_error && !output.status.success() {
return Error::InstallExecute(entry.0.to_string(), output.status.code()).error();
}

installed.insert(entry.0.as_str());
}

installed.insert(entry.0.as_str());
}

if !(install_command.skip_all_dependencies || install_command.skip_dependencies) {
Expand Down Expand Up @@ -186,7 +184,7 @@ impl Command for Install {

let mut installed: HashSet<&str> = HashSet::new();
for dot in dots.iter() {
if install_command.dots.contains(&"".to_string()) || install_command.dots.contains(dot.0) {
if install_command.dots.contains(&"*".to_string()) || install_command.dots.contains(dot.0) {
self.install(&dots, dot, &mut installed, IndexSet::new(), (&globals, &install_command))?;
}
}
Expand Down
Loading

0 comments on commit 331d4ff

Please sign in to comment.