Skip to content

Commit 0077d0f

Browse files
authored
Merge pull request #64 from volllly/fix/windows-shell-command
Fix the default windows shell command
2 parents 96d840d + 7a412c3 commit 0077d0f

10 files changed

Lines changed: 1434 additions & 1436 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.6.1] - 2022-08-18
10+
11+
### Changed
12+
13+
- The repo level config file now uses the key `global` instead of `default`
14+
- The default `shell_command` on windows now correctly uses PowerShell instead of PowerShell Core.
15+
16+
### Fixed
17+
18+
- The repo level config file can now override config default values
19+
920
## [0.6.0] - 2022-07-29
1021

1122
### Added
@@ -117,7 +128,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
117128
- Dotfile linking
118129
- Error handling
119130

120-
[Unreleased]: https://github.com/volllly/rotz/compare/v0.6.0...HEAD
131+
[Unreleased]: https://github.com/volllly/rotz/compare/v0.6.1...HEAD
132+
[0.6.1]: https://github.com/volllly/rotz/releases/tag/v0.6.1
121133
[0.6.0]: https://github.com/volllly/rotz/releases/tag/v0.6.0
122134
[0.5.0]: https://github.com/volllly/rotz/releases/tag/v0.5.0
123135
[0.4.1]: https://github.com/volllly/rotz/releases/tag/v0.4.1

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rotz"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
edition = "2021"
55
authors = ["Paul Volavsek <paul.volavsek@gmail.com>"]
66
license = "MIT"

docs/docs/configuration/config.yaml.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This settig allows to specify how Rotz should launch the install command.
2121
If this is not set the default values are used.
2222

2323
```yaml title="Windows"
24-
shell_command: pwsh -NoProfile -C {{ quote "" cmd }}
24+
shell_command: powershell -NoProfile -C {{ quote "" cmd }}
2525
```
2626

2727
```yaml title="Linux"
@@ -49,7 +49,7 @@ variables:
4949
It is possible to put a config file in your repo conatining default values depending on the OS. These are overridden by the config file on the machine.
5050

5151
```yaml title=".dotfiles/config.yaml"
52-
default:
52+
global:
5353
link_type: <globalDefault>
5454
5555
windows:

docs/package-lock.json

Lines changed: 1389 additions & 1418 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
"typecheck": "tsc"
1616
},
1717
"dependencies": {
18-
"@docusaurus/core": "2.0.0-rc.1",
19-
"@docusaurus/preset-classic": "2.0.0-rc.1",
20-
"@easyops-cn/docusaurus-search-local": "0.30.2",
18+
"@docusaurus/core": "2.0.1",
19+
"@docusaurus/preset-classic": "2.0.1",
20+
"@easyops-cn/docusaurus-search-local": "0.31.0",
2121
"@mdx-js/react": "1.6.22",
2222
"clsx": "1.2.1",
2323
"prism-react-renderer": "1.3.5",
2424
"react": "17.0.2",
2525
"react-dom": "17.0.2"
2626
},
2727
"devDependencies": {
28-
"@docusaurus/module-type-aliases": "2.0.0-rc.1",
28+
"@docusaurus/module-type-aliases": "2.0.1",
2929
"@tsconfig/docusaurus": "1.0.6",
3030
"typescript": "4.7.4"
3131
},
@@ -41,4 +41,4 @@
4141
"last 1 safari version"
4242
]
4343
}
44-
}
44+
}

src/commands/install.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
22

33
use crossterm::style::{Attribute, Stylize};
44
use indexmap::IndexSet;
5-
use miette::{Diagnostic, Result};
5+
use miette::{Diagnostic, Report, Result};
66
use serde_json::json;
77
use somok::Somok;
88

@@ -100,8 +100,18 @@ impl Install {
100100
println!("{}{}{}\n", Attribute::Italic, inner_cmd, Attribute::Reset);
101101

102102
if let Err(err) = helpers::run_command(&cmd[0], &cmd[1..], false, globals.dry_run) {
103+
if let helpers::RunError::Spawn(err) = &err {
104+
if let std::io::ErrorKind::NotFound = err.kind() {
105+
println!("kek");
106+
}
107+
}
108+
109+
let error = Error::InstallExecute(entry.0.to_string(), err);
110+
103111
if !install_command.continue_on_error {
104-
return Error::InstallExecute(entry.0.to_string(), err).error();
112+
return error.error();
113+
} else {
114+
eprintln!("\n Error: {:?}", Report::new(error));
105115
}
106116
}
107117

src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use somok::Somok;
1717
use crate::USER_DIRS;
1818

1919
#[derive(Debug, ArgEnum, Clone, Display, Deserialize, Serialize, IsVariant)]
20-
#[cfg_attr(test, derive(Dummy, PartialEq))]
20+
#[cfg_attr(test, derive(Dummy, PartialEq, Eq))]
2121
pub enum LinkType {
2222
/// Uses symbolic links for linking
2323
Symbolic,
@@ -42,7 +42,7 @@ impl Dummy<ValueFaker> for HashMap<String, serde_json::Value> {
4242
}
4343

4444
#[derive(Deserialize, Serialize, Debug)]
45-
#[cfg_attr(test, derive(Dummy, PartialEq))]
45+
#[cfg_attr(test, derive(Dummy, PartialEq, Eq))]
4646
pub struct Config {
4747
/// Path to the local dotfiles
4848
pub(crate) dotfiles: PathBuf,
@@ -66,7 +66,7 @@ impl Default for Config {
6666
dotfiles: USER_DIRS.home_dir().join(".dotfiles"),
6767
link_type: LinkType::Symbolic,
6868
#[cfg(windows)]
69-
shell_command: Some("pwsh -NoProfile -C {{ quote \"\" cmd }}".to_string()),
69+
shell_command: Some("powershell -NoProfile -C {{ quote \"\" cmd }}".to_string()),
7070
#[cfg(all(not(target_os = "macos"), unix))]
7171
shell_command: Some("bash -c {{ quote \"\" cmd }}".to_string()),
7272
#[cfg(target_os = "macos")]

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(crate) mod os {
5555

5656
#[derive(thiserror::Error, Diagnostic, Debug)]
5757
pub(crate) enum RunError {
58-
#[error("Cloud not spawn command")]
58+
#[error("Could not spawn command")]
5959
#[diagnostic(code(process::command::spawn))]
6060
Spawn(#[source] io::Error),
6161

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,13 @@ fn main() -> Result<(), miette::Report> {
9191
iter.next();
9292
config.dotfiles = USER_DIRS.home_dir().iter().chain(iter).collect();
9393
}
94-
config = join_repo_config(&config.dotfiles.join(format!("config.{FILE_EXTENSION}")), config_figment)?
95-
.select(os::OS.to_string().to_ascii_lowercase())
94+
95+
config_figment = join_repo_config(&config.dotfiles.join(format!("config.{FILE_EXTENSION}")), config_figment)?;
96+
97+
config = config_figment
98+
.clone()
99+
.select("global")
100+
.merge(config_figment.select(os::OS.to_string().to_ascii_lowercase()))
96101
.extract()
97102
.map_err(Error::ParsingConfig)?;
98103

0 commit comments

Comments
 (0)