Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ jobs:
with:
node-version: 24
cache: pnpm
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install
- name: create npm dirs
Expand All @@ -273,29 +274,24 @@ jobs:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
SHA: ${{ github.event.pull_request.head.sha }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [ "${{ github.event.pull_request.head.repo.fork }}" = "true" ]
then
echo "Fork PR, skipping publish"
exit 0
fi

npm config set provenance true

MESSAGE="$(gh api "repos/$REPO/commits/$SHA" --jq '.commit.message')"
FIRST_LINE="$(printf '%s' "$MESSAGE" | head -n 1 | tr -d '\r')"

echo "Latest commit: $FIRST_LINE"

if printf '%s' "$FIRST_LINE" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
npm publish --provenance --access public
elif printf '%s' "$FIRST_LINE" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+'
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
npm publish --provenance --tag next --access public
else
echo "Not a release, skipping publish"
fi
11 changes: 11 additions & 0 deletions __test__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,25 @@ describe('diff fingerprint', () => {
return res
}

const generateFingerprintFromPath = (name: string) => {
const diffPath = path.join(fixturesDir, name)
console.time(`${name}-path`)
const res = fingerprintDiff(diffPath)
console.timeEnd(`${name}-path`)
return res
}
Comment thread
gregberge marked this conversation as resolved.

const fA1 = generateFingerprintFromFilename('diff-A1.png')
const fA1Path = generateFingerprintFromPath('diff-A1.png')
const fA2 = generateFingerprintFromFilename('diff-A2.png')
const fA3 = generateFingerprintFromFilename('diff-A3.png')
const fB1 = generateFingerprintFromFilename('diff-B1.png')
const fLong = generateFingerprintFromFilename('long-diff.png')

expect(fA1).toBe('v1:g16:d1:t0.002,0.02,0.08:202566ca9533046b')
expect(fA1).toBe(fA2)
expect(fA1).toBe(fA3)
expect(fA1).toBe(fA1Path)
expect(fA1).not.toBe(fB1)
expect(fLong).not.toBe(fB1)
})
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare function fingerprintDiff(pngBytes: Buffer, options?: JsEqualityFingerprintOptions | undefined | null): string
export declare function fingerprintDiff(pngInput: string | Buffer, options?: JsEqualityFingerprintOptions | undefined | null): string

export interface JsEqualityFingerprintOptions {
redThreshold?: JsRedThreshold
Expand Down
Loading