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
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ ci: add a dev container
chore: declare the Node version for local development
docs: trim local setup to the essentials
```

## Build outputs

`imagediff.js` and `imagediff.min.js` are generated by `npm run build` and committed for releases. Rebuild and commit them only when preparing a release; ordinary PRs change `js/imagediff.js` and leave the built files alone. `npm test` runs against the source, including the CLI, so nothing needs rebuilding to test a change.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ npm test

### Scripts

* `npm test` runs the specs in Node.js and then in headless Chromium, and fails if either fails.
* `npm test` runs the specs in Node.js and then in headless Chromium, and fails if either fails. The specs and the CLI use the source in `js/`, so no build is needed first.
* `npm run test:node` runs the specs, including a smoke test of the `imagediff` CLI, in Node.js against [node-canvas](https://github.com/Automattic/node-canvas) (the optional `canvas` dependency, which `npm ci` installs from prebuilt binaries on common platforms).
* `npm run test:browser` runs the specs in headless Chromium with Playwright.
* `npm run test:serve` serves the specs at http://localhost:8085/spec/ to watch them run in a browser.
* `npm run build` (or `make imagediff`) writes `imagediff.js` (license header + `js/imagediff.js`) and `imagediff.min.js`, minified with [terser](https://terser.org/) to ES5 output.
* `npm run build` (or `make imagediff`) writes `imagediff.js` (license header + `js/imagediff.js`) and `imagediff.min.js`, minified with [terser](https://terser.org/) to ES5 output. Run it only when preparing a release; see [CONTRIBUTING.md](CONTRIBUTING.md#build-outputs).

### Dev container

Expand Down
2 changes: 1 addition & 1 deletion bin/imagediff
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
var
fs = require('fs'),
imagediff = require('../imagediff.js'),
imagediff = require('../js/imagediff.js'),
Canvas = require('canvas');

commandLine(process.argv.slice(2));
Expand Down
4 changes: 2 additions & 2 deletions spec/LoadSpec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Loads the built library in a fresh Node process, the way bundlers and
// Loads the library source in a fresh Node process, the way bundlers and
// installs without the optional `canvas` dependency see it.
var
childProcess = require('child_process'),
path = require('path');

describe('loading imagediff', function () {

var LIBRARY = path.join(__dirname, '..', 'imagediff.js');
var LIBRARY = path.join(__dirname, '..', 'js', 'imagediff.js');

// Runs `body` in a child process with `canvas` unresolvable and calls back
// with the JSON it prints.
Expand Down
Loading