Skip to content

Commit

Permalink
Fix command path bug and bug where empty config is seen as invalid
Browse files Browse the repository at this point in the history
- Executed paths are now wrapped in quotes
- Non-existant config.toml is now allowed and uses default config
  • Loading branch information
JamyGolden committed Feb 20, 2024
1 parent c2c48a5 commit ad56456
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.10.1 (2024-02-20)

- Fix bug where spaces in config or data directory paths would cause
`install` and `update` to fail
- Fix bug so now tinty works without a `config.toml` file being provided

## 0.10.0 (2024-02-19)

- **Breaking**: Change `--config` flag to accept a path to config file
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tinty"
description = "Change the theme of your terminal, text editor and anything else with one command!"
version = "0.10.0"
version = "0.10.1"
edition = "2021"
license = "MIT"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion license.html
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,7 @@ <h4>Used by:</h4>
<h3 id="MIT">MIT License</h3>
<h4>Used by:</h4>
<ul class="license-used-by">
<li><a href=" https://github.com/tinted-theming/tinty ">tinty 0.10.0</a></li>
<li><a href=" https://github.com/tinted-theming/tinty ">tinty 0.10.1</a></li>
</ul>
<pre class="license-text">MIT License

Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn ensure_item_name_is_unique(items: &[ConfigItem]) -> Result<()> {

impl Config {
pub fn read(path: &Path) -> Result<Config> {
if !path.is_file() {
if path.exists() && !path.is_file() {
return Err(anyhow!(
"The provided config path is a directory and not a file: {}",
path.display()
Expand Down
7 changes: 0 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ fn main() -> Result<()> {
)
})?;

if !config_path.exists() {
return Err(anyhow!(
"Config path does not exist: {}",
config_path.display()
));
}

// Handle the subcommands passed to the CLI
match matches.subcommand() {
Some(("current", _)) => {
Expand Down
2 changes: 1 addition & 1 deletion src/operations/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub fn apply(config_path: &Path, data_path: &Path, full_scheme_name: &str) -> Re
// Run hook for item if provided
if let Some(hook_text) = &item.hook {
let hook_script =
hook_text.replace("%f", format!("{}", theme_file_path.display()).as_str());
hook_text.replace("%f", format!("\"{}\"", theme_file_path.display()).as_str());
let command_vec =
get_shell_command_from_string(config_path, hook_script.as_str())?;
Command::new(&command_vec[0])
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn git_clone(repo_url: &str, target_dir: &Path) -> Result<()> {
));
}

let command = format!("git clone {} {}", repo_url, target_dir.display());
let command = format!("git clone \"{}\" \"{}\"", repo_url, target_dir.display());
let command_vec = shell_words::split(command.as_str()).map_err(anyhow::Error::new)?;

Command::new(&command_vec[0])
Expand Down

0 comments on commit ad56456

Please sign in to comment.