New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@dmouse/keywords_replacer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dmouse/keywords_replacer

Replace some keywords in files easier.

latest
npmnpm
Version
1.0.11
Version published
Maintainers
1
Created
Source

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"
  }]
}

FAQs

Package last updated on 08 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts