Skip to content

Commit

Permalink
refactor: Directory access into file list of config
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed Apr 1, 2024
1 parent b48d3ac commit 35accb4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn update(base_config: &Config, new_version: &Version) -> Result<()> {
&("current_version = \"{{current_version}}\"".to_string()),
&("current_version = \"{{new_version}}\"".to_string()),
);
for f in base_config.get_files() {
for f in &base_config.files {
writer.add_target(&f.path, &f.search, &f.replace);
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn execute(_args: &Arguments, config: &Config) -> Result<()> {
ctx.insert("next_major", &versioning::up_major(&config.current_version));
ctx.insert("next_minor", &versioning::up_minor(&config.current_version));
ctx.insert("next_patch", &versioning::up_patch(&config.current_version));
for f in config.get_files() {
for f in &config.files {
files.push(f.path.display().to_string());
}
ctx.insert("files", &files);
Expand Down
8 changes: 1 addition & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub const DEFAULT_FILENAME: &'static str = ".age.toml";
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Config {
pub current_version: Version,
files: Vec<FileConfig>,
pub files: Vec<FileConfig>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand All @@ -23,12 +23,6 @@ pub struct FileConfig {
pub replace: String,
}

impl Config {
pub fn get_files(&self) -> &Vec<FileConfig> {
&self.files
}
}

pub fn resolve_config() -> Result<Config> {
let pwd = current_dir().unwrap();
let config_path = pwd.join(Path::new(DEFAULT_FILENAME));
Expand Down

0 comments on commit 35accb4

Please sign in to comment.