regex-bumper
v1.0.0
Published
Cli tool to bump numbers in files based on regexes
Maintainers
Readme
Regex bumper
Cli tool to bump numbers in files based on regexes.
Content
🚀 Installation
Install Regex bumper with npm
npm install -g regex-bumper💻 Usage
First .rbumprc.json need to be created where regex-bumper will be executing or a path to this file should be specified by --config parameter.
.rbumprc.json contains paths to files in which the number will be increased and regexes according to which the numbers will be found and subsequently increased.
It is possibly also using flags for regex in flags property of file configuration (for example global flag).
Files property can contain multiple file definitions.
The number captured in a capture group of regex will be increased using this CLI.
{
"files": [
{
"path": "./file.json",
"regex": "\"num\": \"(\\d+)\"",
"flags": "g"
}
]
}The tool can be executed by running when numbers should be bumped by 1 like:
regex-bumperor when numbers should be bumped to a specific number like:
regex-bumper --value 100It is also possible to define a path to .rbumprc.json like:
regex-bumper --config ./path/.rbumprc.jsonPath variables
Path variables are variable path fragments that can be unique for specific environments. For example, one developer can have some files stored in a specific directory, while the second developer has files stored in another directory. In this situation path variables come handy.
{
"files": [
{
"path": "{HOME}/package.json",
"regex": "\"version\"=\"(\\d+)\""
}
]
}In this example, the developer is first prompted to create {HOME} path variable when executing regex-bumper for first time.
These variables are stored for future use by default in .varpath in location where regex-bumper is executed.
It is also possible to define a custom .varpath file location or name in .rbumprc.json config.
The path is relative to where regex-bumper is executed.
{
"varPathFile": "./.varpath.txt",
"files": [
{
"path": "{HOME}/package.json",
"regex": "\"version\"=\"(\\d+)\""
}
]
}