#!/bin/sh
set -e
# notice the / at end in order to load this module
PACKAGE='cipher-base'
SEDCMD="s,require\s*[(]\s*'[.][^']*'\s*[)],require('$PACKAGE'),g"

tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT INT TERM HUP

cp  test.js $tmpdir/test.js
echo 'test.js' |
    xargs -n1  sh -c 'set -e; echo "TESTING: $3"; sed "$1" < "$3" > "$2/$3"' sedtape "$SEDCMD" "$tmpdir"
tape $tmpdir/test.js
