Skip to content

Commit

Permalink
modernize, switch to ESM, GH Actions, ESLint 9+
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jun 26, 2024
1 parent ced69a3 commit 16f88ce
Show file tree
Hide file tree
Showing 9 changed files with 1,170 additions and 688 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Node
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 18

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Run the CLI tool
run: node bin/pixelmatch test/fixtures/1a.png test/fixtures/1b.png
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

9 changes: 3 additions & 6 deletions bin/pixelmatch
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/usr/bin/env node
/* eslint-disable no-process-exit */

'use strict';

const PNG = require('pngjs').PNG;
const fs = require('fs');
const match = require('../.');
import {PNG} from 'pngjs';
import fs from 'fs';
import match from '../index.js';

if (process.argv.length < 4) {
console.log('Usage: pixelmatch image1.png image2.png [diff.png] [threshold] [includeAA]');
Expand Down
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import config from 'eslint-config-mourner';

export default [
...config,
{
files: ['*.js', 'test/test.js', 'bin/pixelmatch']
}
];
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
'use strict';

module.exports = pixelmatch;

const defaultOptions = {
threshold: 0.1, // matching threshold (0 to 1); smaller is more sensitive
Expand All @@ -12,7 +9,7 @@ const defaultOptions = {
diffMask: false // draw the diff over a transparent background (a mask)
};

function pixelmatch(img1, img2, output, width, height, options) {
export default function pixelmatch(img1, img2, output, width, height, options) {

if (!isPixelData(img1) || !isPixelData(img2) || (output && !isPixelData(output)))
throw new Error('Image data: Uint8Array, Uint8ClampedArray or Buffer expected.');
Expand Down
Loading

0 comments on commit 16f88ce

Please sign in to comment.