@shanzhai/change-tracking-helpers
TypeScript icon, indicating that this package has built-in type declarations

0.0.14 • Public • Published

@shanzhai/change-tracking-helpers Continuous Integration License FOSSA Status Renovate enabled npm npm type definitions

Helpers for tracking changes to files during a Shanzhai build.

Usage

This is a collection of helpers. Each requires its own explanation.

Generating Diffs

The generateDiff function compares two objects containing key-value pairs.

The differences between them are returned.

import { generateDiff } from "@shanzhai/change-tracking-helpers";

generateDiff({
  testRemoved: 123,
  testChanged: 456,
  testUnchanged: 789,
}, {
  testChanged: 456,
  testUnchanged: 789,
  testAdded: 101112,
});

This will return the following:

{
  added: [`testAdded`],
  changed: [`testChanged`],
  deleted: [`testDeleted`],
  unchanged: [`testUnchanged`],
};

Hashing files

The hashFile function resolves to the SHA-1 hash of a file.

As a reminder, SHA-1 is considered suitable for change tracking but not for protecting against malicious changes.

import { hashFile } from "@shanzhai/change-tracking-helpers";

await hashFile(`a/file/path`);

This will resolve to a string containing the hash in hexadecimal.

Filtering out common temporary or system files

The pathAccepted function determines whether a given string appears to be a temporary or system file or not.

import { pathAccepted } from "@shanzhai/change-tracking-helpers";

pathAccepted(`a/file/path`);

Some examples of paths which would not be accepted:

  • .a-dotfile
  • a/nested/.dotfile/path

Dependencies

This package has no runtime dependencies.

Peer Dependencies

This package has no runtime peer dependencies (it does not expect any other packages to be installed alongside itself).

License

FOSSA Status

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i @shanzhai/change-tracking-helpers

    Weekly Downloads

    7

    Version

    0.0.14

    License

    MIT

    Unpacked Size

    8.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • jameswilddev