@dmouse/keyswords_replacer v1.0.4
Keyswords Replacer
Replace some keywords in foles easier.
It need a configuration file to config some keywords for replace. It's a JSON file default name keywords-replacer.config.json
, and then run node keywords-replacer
. A configuration file can also be specified with the node keywords-replacer -c config.json
command.
In configuration file, under the file array is the file to be processed, in
is the source file, out
is the save location after processing, minify
is to compress the code, default is false
, bookmarklet
is to process the code into bookmarklet format, default is false
, this function is not widely used.
Under the keys
object is the content to be replaced, like this "version": "0.1.7"
, replace ```version```
in the file with 0.1.7
.
The program will read the fields in package.json as keywords, but the arrays and objects may not be replaced as expected. However, this already allows us to just modify the version number in the package.json, you can use this tool to apply everywhere. Note: The same attributes are overridden by the settings in keys
.
The program automatically generates a keyword called nowTime
, which corresponds to the time in 2020-09-05 19:20:22
format. It can also be overridden by the settings in keys
.
You can also use the filekeys
array to set the keywords to the content of a file.
imgkeys
can be used to replace keywords with the base64 format Data URI of the image. (But it may only work for png format, so I think it's good enough.)
example:
{
"files": [
{
"in": "./Greasemonkey/Script.js",
"out": "./dist/Link-Cleaner.user.js"
},
{
"in": "./Bookmarklet/Link-Cleaner.js",
"out": "./dist/Link-Cleaner.bookmarklet.js",
"minify": true,
"bookmarklet": true
},
{
"in": "./Pages/Readme.md",
"out": "./Readme.md"
}
],
"keys": {
"version": "0.1.7"
},
"fileKeys": [
{
"key": "scripts_rules_js",
"file": "./Scripts/rules.js"
},
{
"key": "scripts_main_js",
"file":"./Scripts/main.js"
},
{
"key": "greasymonkey_style",
"file": "./Greasemonkey/Style.css"
},
{
"key": "greasymonkey_DOM",
"file": "./Greasemonkey/DOM.html"
},
{
"key": "theBookmarkletCode",
"file": "./dist/Link-Cleaner.bookmarklet.js"
}
],
"imgKeys": [{
"key": "logo",
"file": "./logo.png"
}]
}