Skip to content

Latest commit

 

History

History
75 lines (58 loc) · 1.45 KB

json.md

File metadata and controls

75 lines (58 loc) · 1.45 KB

JSON File Replacer

If you specify a JSON File Replacer, it will parse the JSON file specified and replace the key with the new version. Nested keys are supported using ..

Example 1: package.json

If you specify the following in your .semver config file:

file_replacers:
  - type: json
    name: package.json
    key: version
    format: "v%M.%m.%p"

Given the following contents for package.json:

{
  "name": "my package",
  "version": "v0.0.0"
}

When creating v1.0.0, the PageKey Semver will replace the package.json with the following:

{
  "name": "my_package",
  "version": "v1.0.0"
}

Note that the value will always be replaced with the format you specified in the config, regardless of the previous value.

Example 2: Nested Keys

If you specify the following in your .semver config file:

file_replacers:
  - type: json
    name: package.json
    key: project.metadata.version
    format: "v%M.%m.%p"

Given the following contents for package.json:

{
  "name": "my package",
  "project": {
    "metadata": {
        "version": "v0.0.0"
    }
  }
}

When creating v1.0.0, the PageKey Semver will replace the package.json with the following:

{
  "name": "my package",
  "project": {
    "metadata": {
        "version": "v1.0.0"
    }
  }
}

Note that the value will always be replaced with the format you specified in the config, regardless of the previous value.