Skip to content

npm module to hash the contents of files matched by globs

License

Notifications You must be signed in to change notification settings

markguckian/glob-hash

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

glob-hash

npm module to hash the contents of files matched by globs

MIT License Badge npm Build Status Code Climate

Via Command line

Install

npm install -g glob-hash

Use

Note: option -i/--include is mandatory

Usage: glob-hash [options]

Options:

-h, --help                output usage information
-V, --version             output the version number
-i, --include <glob>      Files to include. Mandatory. May be used multiple times.
-e, --exclude [glob]      Files to exclude. May be used multiple times.
-a, --algorithm [string]  The hashing algorithm to use. Defaults to "sha256".
-f, --files               Show matched files and exit.
-j, --jail [path]         A jail path. Reading outside the jail path will throw an error.

Via API

Install

npm install glob-hash --save

Use

Sample

var globHash = require('glob-hash');

globHash(options)
.then(function(hash) {
    console.log(hash);
}, function(error) {
    console.log(error);
});

Options

Array include - An array of globs used to match the files to hash. Mandatory option.

Array exclude - An array of globs to exclude from the search.

String algorithm - The hashing algorithms to use. Defaults to "sha256", see crypto.getHashes.

Boolean files - Returns an array of files matched by the globs, instead of returning the hash.

String jail - A jail path. Reading outside the jail path will throw an error. Defaults to never throwing.

More samples

// Get hash
globHash({
    include: ['src/**/*.js', '**/*.json'],
    exclude: ['package.json'],
    algorithm: 'sha256' // This is the default
})
.then(
    function(result) {
        console.log(result);
    },
    function(error) {
        console.log(error);
    }
);
// Get list of matched files
globHash({
    include: ['src/**/*.js', '**/*.json'],
    exclude: ['package.json'],
    files: true
})
.then(
    function(result) {
        console.log(result);
    },
    function(error) {
        console.log(error);
    }
);

Test

npm test

About

npm module to hash the contents of files matched by globs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.9%
  • Scilab 0.1%