Skip to content

Commit c92991c

Browse files
feat(hdiff): update CLI wrapper
- check if `bun` is available, otherwise fallback to `node`
1 parent f833fe6 commit c92991c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/hdiff/bin/hdiff

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22

33
# https://stackoverflow.com/a/246128/294515
44
SOURCE="${BASH_SOURCE[0]}"
5-
while [ -h "$SOURCE" ]; do
5+
while [ -L "$SOURCE" ]; do
66
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
77
SOURCE="$(readlink "$SOURCE")"
88
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
99
done
1010
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
11+
DIR="$(dirname $DIR)"
1112

12-
/usr/bin/env node "$DIR/../cli.js" "$@"
13+
# prefer using bun
14+
if [ -x "$(command -v bun)" ]; then
15+
CMD=bun
16+
else
17+
CMD=node
18+
fi
19+
20+
/usr/bin/env $CMD "$DIR/cli.js" "$DIR" "$@"

packages/hdiff/src/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let src1;
99
let src2;
1010
let headerBody;
1111

12-
const args = process.argv.slice(2);
12+
const args = process.argv.slice(3);
1313
if (args.length === 3) {
1414
const [path, rev1, rev2] = args;
1515
src1 = execSync(`git show ${rev1}:${path}`).toString();

0 commit comments

Comments
 (0)