diff options
author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-27 15:30:14 +0530 |
---|---|---|
committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-27 15:30:14 +0530 |
commit | cb3072066dc482cbadfbd77c64b7e61a1b24b9c6 (patch) | |
tree | 4d16baf85a519670ca8647b0b11abb1c54fc0bad /zellij-utils/src/setup.rs | |
parent | 1e5c688ed99fe7f96e5e690fba70d80782a53d3d (diff) |
hotfix(publish): Move install module and asset_map to main zellij package. publish should hopefully work now.
Diffstat (limited to 'zellij-utils/src/setup.rs')
-rw-r--r-- | zellij-utils/src/setup.rs | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index 0d442f0f7..d7ddefe4d 100644 --- a/zellij-utils/src/setup.rs +++ b/zellij-utils/src/setup.rs @@ -2,61 +2,16 @@ use crate::cli::CliArgs; use crate::consts::{ FEATURES, SYSTEM_DEFAULT_CONFIG_DIR, SYSTEM_DEFAULT_DATA_DIR_PREFIX, VERSION, ZELLIJ_PROJ_DIR, }; -use crate::shared::set_permissions; use directories_next::BaseDirs; use serde::{Deserialize, Serialize}; use std::io::Write; -use std::{fs, path::Path, path::PathBuf}; +use std::{path::Path, path::PathBuf}; use structopt::StructOpt; const CONFIG_LOCATION: &str = ".config/zellij"; const CONFIG_NAME: &str = "config.yaml"; static ARROW_SEPARATOR: &str = ""; -#[macro_export] -macro_rules! asset_map { - ($($src:literal => $dst:literal),+ $(,)?) => { - { - let mut assets = std::collections::HashMap::new(); - $( - assets.insert($dst, include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/", $src)).to_vec()); - )+ - assets - } - } -} - -pub mod install { - use super::*; - - pub fn populate_data_dir(data_dir: &Path) { - // First run installation of default plugins & layouts - let mut assets = asset_map! { - "../assets/layouts/default.yaml" => "layouts/default.yaml", - "../assets/layouts/strider.yaml" => "layouts/strider.yaml", - }; - assets.extend(asset_map! { - "../assets/plugins/status-bar.wasm" => "plugins/status-bar.wasm", - "../assets/plugins/tab-bar.wasm" => "plugins/tab-bar.wasm", - "../assets/plugins/strider.wasm" => "plugins/strider.wasm", - }); - assets.insert("VERSION", VERSION.as_bytes().to_vec()); - - let last_version = fs::read_to_string(data_dir.join("VERSION")).unwrap_or_default(); - let out_of_date = VERSION != last_version; - - for (path, bytes) in assets { - let path = data_dir.join(path); - let parent_path = path.parent().unwrap(); - fs::create_dir_all(parent_path).unwrap(); - set_permissions(parent_path).unwrap(); - if out_of_date || !path.exists() { - fs::write(path, bytes).expect("Failed to install default assets!"); - } - } - } -} - #[cfg(not(any(feature = "test", test)))] /// Goes through a predefined list and checks for an already /// existing config directory, returns the first match |