package-hash

WebJar for package-hash

Лицензия

Лицензия

ISC
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

package-hash
Последняя версия

Последняя версия

3.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

package-hash
WebJar for package-hash
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/novemberborn/package-hash

Скачать package-hash

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/package-hash/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>package-hash</artifactId>
    <version>3.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/package-hash/
implementation 'org.webjars.npm:package-hash:3.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/package-hash/
implementation ("org.webjars.npm:package-hash:3.0.0")
'org.webjars.npm:package-hash:jar:3.0.0'
<dependency org="org.webjars.npm" name="package-hash" rev="3.0.0">
  <artifact name="package-hash" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='package-hash', version='3.0.0')
)
libraryDependencies += "org.webjars.npm" % "package-hash" % "3.0.0"
[org.webjars.npm/package-hash "3.0.0"]

Зависимости

compile (4)

Идентификатор библиотеки Тип Версия
org.webjars.npm : graceful-fs jar [4.1.15,5)
org.webjars.npm : hasha jar [3.0.0,4)
org.webjars.npm : lodash.flattendeep jar [4.4.0,5)
org.webjars.npm : release-zalgo jar [1.0.0,2)

Модули Проекта

Данный проект не имеет модулей.

package-hash

Generates a hash for an installed npm package, useful for salting caches. AVA for example caches precompiled test files. It generates a salt for its cache based on the various packages that are used when compiling the test files.

package-hash can generate an appropriate hash based on the package location (on disk) and the package.json file. This hash is salted with a hash for the package-hash itself.

package-hash can detect when the package-to-be-hashed is a Git repository. In the AVA example this is useful when you're debugging one of the packages used to compile the test files. You can clone it locally and use npm link so AVA can find the clone. The hash will include the HEAD (.git/HEAD) and its corresponding ref (e.g. .git/refs/heads/master), any packed refs (.git/packed-refs), as well as the diff (git diff) for any non-committed changes. This makes it really easy to test your changes without having to explicitly clear the cache in the parent project.

Installation

$ npm install --save package-hash

Usage

const packageHash = require('package-hash')

// Asynchronously:
const hash = await packageHash(require.resolve('babel-core/package.json'))

// Synchronously:
const hash = packageHash.sync(require.resolve('babel-core/package.json'))

packageHash() / packageHash.sync() must be called with a file path for an existing package.json file. To get the path to an npm package it's easiest to use require.resolve('the-name/package.json').

You can provide multiple paths:

const hash = await packageHash([
  require.resolve('babel-core/package.json'),
  require.resolve('babel-preset-es2015/package.json')
])

An optional salt value can also be provided:

const hash = await packageHash(require.resolve('babel-core/package.json'), 'salt value')

API

packageHash(paths, salt?)

paths: string | string[] ➜ can be a single file path, or an array of paths.

salt: Array | Buffer | Object | string ➜ optional. If an Array or Object (not null) it is first converted to a JSON string.

Returns a promise for the hex-encoded hash string.

packageHash.sync(paths, salt?)

paths: string | string[] ➜ can be a single file path, or an array of paths.

salt: Array | Buffer | Object | string ➜ optional. If an Array or Object (not null) it is first converted to a JSON string.

Returns a hex-encoded hash string.

Compatibility

package-hash has been tested with Node.js 8 and above, including Windows support.

Версии библиотеки

Версия
3.0.0