1.1.3 • Published 2 years ago

generate-hash-files v1.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Generate hash files

Import

npm install generate-hash-files

or

yarn add generate-hash-files

Config

Create file generate-hash-files.json (if not exist)

Sample:

{
    "files": [
        {
            "id": "Your name",
            "input": "./build/",
            "output": "./dist/",
            "indexFile": "index.json"
        }
    ]
}

files

Set of release.

files.id

Id of config.

files.input

Path of folder that contains files to hash

files.output

Path of output folder that contains copied files. If omitted, no file is copied.

files.indexFile

Index json file path. If ommited, index file is index.json

files.extensions

List of supported file extensions.

Sample:

{
    "extensions": [ ".html", ".js", ".css" ]
}

if extensions was omitted, the default extension list will be used: ".html", ".htm", ".css", ".js", ".json", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".webp", ".ttf", ".woff", ".woff2", ".eot", ".mp3", ".mp4", ".avi"

files.exclude

List of exclusion patterns

Sample:

{
    "exclude": [ "data.log", "result_\\d+\\.txt" ]
}

files.inject

Set of injection rules. inject will be ignored if output is omitted or same to input

Sample

{
    "inject": {
        "Replacement token here. Sample: #GIT_GIT_HASH#": {
            "files": [ "./index.html" ],
            "value": "Your value. You need to encode yourself",
            "env": "Environment name. Ex: NODE_ENV",
            "command": "Shell here. Ex: git rev-parse --verify HEAD"
        }
    }
}

Priority order: value then env then command. Lower priority field will be ignored if higher priority exists.

files.inject.files

List of files that will be replaced by value.

files.inject.value

Value to replace

files.inject.env

Environment name that its value will be used to replace (if files.inject.value ommited)

files.inject.command

Shell command will be exectuted and its output will be used to replace (if files.inject.value and files.inject.env ommited)

files.inject.transform

Transform function. One of: stringify, trim, encodeHTML, encodeURIComponent.

silent

Config console output. If silent is true, no message will be outputed.

Sample:

{
    "files": [...],
    "silent": true
}

Usage

npx generate-hash-files
1.1.1

2 years ago

1.1.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.0

3 years ago