Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/maxleiko/pkg-hash

Generates an MD5 hash based on your local source code using package.json "main" as entry and hashing every local require sources using Acorn and a proper AST
https://github.com/maxleiko/pkg-hash

Last synced: 7 days ago
JSON representation

Generates an MD5 hash based on your local source code using package.json "main" as entry and hashing every local require sources using Acorn and a proper AST

Awesome Lists containing this project

README

        

### pkg-hash

Generates an MD5 hash of a CommonJS module using `detective` (JavaScript Acorn parser) to get a list of all the `require's` and hash **only**
the local sources, starting with the "main" field in `package.json`.

### Example
```js
const pkgHash = require('pkg-hash');

const hash = pkgHash('/path/to/a/commonjs/module');
console.log('Hash:', hash);
```

### Purpose
The purpose of `pkg-hash` is to make integrity checks between different versions/installations of an npm module.
I know that npm already gives a hash of your module when you install it, but it does not take source code into account.
[Kevoree](http://kevoree.org) needs to be able to check whether or not a change in the source code has happen in order to update or not a module.
Well, here it is.

### Related

[pkg-hash-cli](https://github.com/maxleiko/pkg-hash-cli)