feat(json-edit): added json-edit to update some json content with next global version #14

Merged
kjuulh merged 5 commits from feat/with-jq-edit into main 2023-08-04 19:56:18 +02:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 56b44cf2e2 - Show all commits

View File

@@ -12,8 +12,6 @@ impl JsonEditOptions {
pub fn execute(&self, path: &Path, next_version: impl AsRef<str>) -> anyhow::Result<()> {
let next_version = next_version.as_ref();
let jq_query = self.jq.replace("%%version%%", next_version);
if !path.exists() {
anyhow::bail!("could not find file at: {}", path.display());
}
@@ -30,7 +28,10 @@ impl JsonEditOptions {
))?;
let output = std::process::Command::new("jq")
.arg(format!("{}", jq_query))
.arg("--arg")
.arg("version")
.arg(next_version)
.arg(&self.jq)
.arg(
abs_path
.to_str()

View File

@@ -40,7 +40,7 @@ pub fn test_can_update_version_in_jq() {
pretty_assertions::assert_eq!(initial_content, actual_file);
let edit_options = JsonEditOptions {
jq: r#".some.nested[].structure.version="%%version%%""#.into(),
jq: r#".some.nested[].structure.version=$version"#.into(),
};
edit_options.execute(&json_file, "v1.0.2").unwrap();