@stryke/hash 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hash-files.cjs +6 -6
- package/dist/hash-files.d.ts +5 -3
- package/dist/hash-files.mjs +1 -1
- package/package.json +2 -2
package/dist/hash-files.cjs
CHANGED
|
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.hashDirectory = hashDirectory;
|
|
7
7
|
exports.hashFiles = hashFiles;
|
|
8
|
-
var _promises = require("node:fs/promises");
|
|
9
8
|
var _listFiles = require("@stryke/fs/files/list-files");
|
|
9
|
+
var _readFiles = require("@stryke/fs/files/read-files");
|
|
10
10
|
var _hash = require("./hash.cjs");
|
|
11
|
-
async function hashFiles(
|
|
11
|
+
async function hashFiles(i, s) {
|
|
12
12
|
const t = {};
|
|
13
|
-
return await Promise.all(
|
|
14
|
-
t[
|
|
13
|
+
return await Promise.all(i.map(async r => {
|
|
14
|
+
t[r] = await (0, _readFiles.readFile)(r);
|
|
15
15
|
})), (0, _hash.hash)(t, s);
|
|
16
16
|
}
|
|
17
|
-
async function hashDirectory(
|
|
18
|
-
return hashFiles(await (0, _listFiles.listFiles)(
|
|
17
|
+
async function hashDirectory(i, s = {}) {
|
|
18
|
+
return s.ignored = s.ignored ?? ["**/node_modules/**", "**/.git/**", "**/.nx/**", "**/.cache/**", "**/tmp/**"], hashFiles(await (0, _listFiles.listFiles)(i, s), s);
|
|
19
19
|
}
|
package/dist/hash-files.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { ListFilesOptions } from "@stryke/fs/files/list-files";
|
|
1
2
|
import type { HashOptions } from "./hash";
|
|
3
|
+
export type HashFilesOptions = HashOptions & ListFilesOptions;
|
|
2
4
|
/**
|
|
3
5
|
* Hash a list of file paths into a string based on the file content
|
|
4
6
|
*
|
|
@@ -6,12 +8,12 @@ import type { HashOptions } from "./hash";
|
|
|
6
8
|
* @param options - Hashing options
|
|
7
9
|
* @returns A hashed string value
|
|
8
10
|
*/
|
|
9
|
-
export declare function hashFiles(files: string[], options?:
|
|
11
|
+
export declare function hashFiles(files: string[], options?: HashFilesOptions): Promise<string>;
|
|
10
12
|
/**
|
|
11
13
|
* Hash a folder path into a string based on the file content
|
|
12
14
|
*
|
|
13
15
|
* @param directoryPath - The folder path to hash
|
|
14
|
-
* @param options - Hashing options
|
|
16
|
+
* @param options - Hashing options. By default, the `node_modules`, `.git`, `.nx`, `.cache`, and `tmp` folders is ignored.
|
|
15
17
|
* @returns A hashed string value
|
|
16
18
|
*/
|
|
17
|
-
export declare function hashDirectory(directoryPath: string, options?:
|
|
19
|
+
export declare function hashDirectory(directoryPath: string, options?: HashFilesOptions): Promise<string>;
|
package/dist/hash-files.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{listFiles as e}from"@stryke/fs/files/list-files";import{readFile as o}from"@stryke/fs/files/read-files";import{hash as n}from"./hash";export async function hashFiles(i,s){const t={};return await Promise.all(i.map(async r=>{t[r]=await o(r)})),n(t,s)}export async function hashDirectory(i,s={}){return s.ignored=s.ignored??["**/node_modules/**","**/.git/**","**/.nx/**","**/.cache/**","**/tmp/**"],hashFiles(await e(i,s),s)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/hash",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing utility functions that hash data using various algorithms.",
|
|
6
6
|
"repository": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"private": false,
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"js-xxhash": "^4.0.0",
|
|
14
|
-
"@stryke/fs": ">=0.
|
|
14
|
+
"@stryke/fs": ">=0.7.0",
|
|
15
15
|
"@stryke/types": ">=0.5.1"
|
|
16
16
|
},
|
|
17
17
|
"publishConfig": { "access": "public" },
|