Pre-update commands (fix #25)
This commit is contained in:
@@ -55,6 +55,14 @@ git_repos = [
|
|||||||
"~/dev/topgrade",
|
"~/dev/topgrade",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[pre_commands]
|
||||||
|
"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"
|
||||||
|
|
||||||
[commands]
|
[commands]
|
||||||
"Python Environment" = "~/dev/.env/bin/pip install -i https://pypi.python.org/simple -U --upgrade-strategy eager jupyter"
|
"Python Environment" = "~/dev/.env/bin/pip install -i https://pypi.python.org/simple -U --upgrade-strategy eager jupyter"
|
||||||
```
|
```
|
||||||
|
* `git_repos` - A list of custom Git repositories to pull
|
||||||
|
* `pre_commands` - Commands to execute before starting any action. If any command fails, Topgrade
|
||||||
|
will not proceed
|
||||||
|
* `commands` - Custom upgrade steps. If any command fails it will be reported in the summary as all
|
||||||
|
upgrade steps are reported, but it will not cause Topgrade to stop.
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ use std::collections::BTreeMap;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
|
type Commands = BTreeMap<String, String>;
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
commands: Option<BTreeMap<String, String>>,
|
pre_commands: Option<Commands>,
|
||||||
|
commands: Option<Commands>,
|
||||||
git_repos: Option<Vec<String>>,
|
git_repos: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +33,11 @@ impl Config {
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn commands(&self) -> &Option<BTreeMap<String, String>> {
|
pub fn pre_commands(&self) -> &Option<Commands> {
|
||||||
|
&self.pre_commands
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn commands(&self) -> &Option<Commands> {
|
||||||
&self.commands
|
&self.commands
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,13 @@ fn run() -> Result<(), Error> {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(commands) = config.pre_commands() {
|
||||||
|
for (name, command) in commands {
|
||||||
|
terminal.print_separator(name);
|
||||||
|
run_custom_command(&command)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if cfg!(target_os = "linux") {
|
if cfg!(target_os = "linux") {
|
||||||
terminal.print_separator("System update");
|
terminal.print_separator("System update");
|
||||||
match linux::Distribution::detect() {
|
match linux::Distribution::detect() {
|
||||||
|
|||||||
Reference in New Issue
Block a user