From 593ff0a9bc2b00cc9821a4a525924219ea62c1fa Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Mon, 22 Feb 2021 13:01:33 +0200 Subject: [PATCH] Support VSCodium (Fix #637) (#639) --- src/config.rs | 1 + src/main.rs | 1 + src/steps/generic.rs | 36 +++++++++++++++++++++++++----------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index bec7a0c3..d009a798 100644 --- a/src/config.rs +++ b/src/config.rs @@ -116,6 +116,7 @@ pub enum Step { Vcpkg, Vim, Vscode, + Vscodium, Wsl, Yadm, } diff --git a/src/main.rs b/src/main.rs index a0ebdd32..162ed259 100644 --- a/src/main.rs +++ b/src/main.rs @@ -279,6 +279,7 @@ fn run() -> Result<()> { )))] runner.execute(Step::Atom, "apm", || generic::run_apm(run_type))?; runner.execute(Step::Vscode, "vscode", || generic::run_vscode(run_type))?; + runner.execute(Step::Vscodium, "vscodium", || generic::run_vscodium(run_type))?; runner.execute(Step::Fossil, "fossil", || generic::run_fossil(run_type))?; runner.execute(Step::Rustup, "rustup", || generic::run_rustup(&base_dirs, run_type))?; runner.execute(Step::Dotnet, ".NET", || generic::run_dotnet_upgrade(&ctx))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index a13809d1..23de1cd9 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -10,10 +10,10 @@ use crate::{ use anyhow::Result; use directories::BaseDirs; use log::debug; -use std::env; use std::io::Write; use std::path::PathBuf; use std::process::Command; +use std::{env, path::Path}; use tempfile::tempfile_in; pub fn run_cargo_update(run_type: RunType) -> Result<()> { @@ -90,15 +90,8 @@ pub fn run_fossil(run_type: RunType) -> Result<()> { run_type.execute(&fossil).args(&["all", "sync"]).check_run() } -pub fn run_vscode(run_type: RunType) -> Result<()> { - let vscode = utils::require("code")?; - - print_separator("Visual Studio Code"); - - let plugins = RunType::Wet - .execute(&vscode) - .args(&["--list-extensions"]) - .check_output()?; +pub fn run_vscode_variant(run_type: RunType, exe: &Path) -> Result<()> { + let plugins = RunType::Wet.execute(&exe).args(&["--list-extensions"]).check_output()?; let mut args = vec!["--force"]; @@ -107,11 +100,32 @@ pub fn run_vscode(run_type: RunType) -> Result<()> { args.push(plugin); } - run_type.execute(&vscode).args(args).check_run()?; + if args.len() == 1 { + println!("No extensions to update"); + return Ok(()); + } + + run_type.execute(&exe).args(args).check_run()?; Ok(()) } +pub fn run_vscodium(run_type: RunType) -> Result<()> { + let vscode = utils::require("codium")?; + + print_separator("Visual Studio Codium"); + + run_vscode_variant(run_type, &vscode) +} + +pub fn run_vscode(run_type: RunType) -> Result<()> { + let vscode = utils::require("code")?; + + print_separator("Visual Studio Code"); + + run_vscode_variant(run_type, &vscode) +} + pub fn run_micro(run_type: RunType) -> Result<()> { let micro = utils::require("micro")?;