jsdelta icon indicating copy to clipboard operation
jsdelta copied to clipboard

JSDelta Cookbook

Open wolfgang42 opened this issue 2 years ago • 2 comments

I don’t use JSDelta very often, so when I do have need for it I generally have to puzzle out how to get it do do what I want again. I'm therefore opening this issue to serve as a collection of recipes for using JSDelta in different situations.

wolfgang42 avatar Mar 19 '22 22:03 wolfgang42

Produce a minimal test case from a Node.js project

predicate.sh:

#!/bin/bash

cd $(dirname $1) # enter directory containing project
yarn install || exit 1 # Install dependencies, or abort with irrelevant error

yarn run some-command # The actual command under test

rm -rf node_modules/ # Delete dependencies (otherwise jsdelta tries to minimize them, too)

and to run it:

# Copy git repo, but strip git data so jsdelta doesn't spend time on it
git clone . /tmp/jsdelta-start
rm -rf /tmp/jsdelta-start/.git
# Run the minimization (note: I don't understand what the `package.json` arg does but this seems to work fine regardless)
# --msg works regardless of whether output is on stdout or stderr
yarn run jsdelta --cmd predicate.sh --msg 'error message goes here' --dir /tmp/jsdelta-start/ package.json

wolfgang42 avatar Mar 19 '22 22:03 wolfgang42

Feel free to open a PR with this content in a Cookbook section.

esbena avatar Mar 21 '22 11:03 esbena