1.0.11 • Published 3 years ago

@dmouse/keywords_replacer v1.0.11

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

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.

If the Add Indent(addIntent) is set in the File Replace settings object, the indent length preceding the current keyword is added to the front of each line in the file.

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.

noMarkedKeys is mean the keyword in files not mark by ```something```, and the same with noMarked. This method is prone to errors, so use it with caution.

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"
  },
  "noMarkedKeys": {
    "something": "not be marked"
  },
  "fileKeys": [
    {
      "key": "scripts_rules_js",
      "file": "./Scripts/rules.js",
      "addIntent": true
    },
    {
      "key": "scripts_main_js",
      "file":"./Scripts/main.js",
      "noMarked": true
    },
    {
      "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"
  }]
}
1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago