Skip to content

Commit 2444bfb

Browse files
committed
mk: reveal failing resolve; activate bash aliases
1 parent ba88821 commit 2444bfb

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

mk/alias-cli.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Activate bash aliases for CLI commands (e.g. ndncat) defined within the codebase.
3+
# This shall be called as:
4+
# source mk/alias-cli.sh
5+
6+
while read -r SCRIPT_REL; do
7+
SCRIPT_ABS=$(realpath "$SCRIPT_REL")
8+
SCRIPT_CMD=$(basename "$SCRIPT_REL")
9+
SCRIPT_CMD="${SCRIPT_CMD%.sh}"
10+
eval "$SCRIPT_CMD() { bash \"$SCRIPT_ABS\" \"\$@\" ; }"
11+
export -f "$SCRIPT_CMD"
12+
done < <(git grep -l loader-import.mjs "$(dirname "${BASH_SOURCE[0]}")"/../pkg)
13+
unset SCRIPT_REL SCRIPT_ABS SCRIPT_CMD

mk/loader.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ export async function resolve(specifier, context, nextResolve) {
3333
}
3434
} catch {}
3535

36-
const r = await K.resolve(specifier, context, nextResolve);
36+
let r;
37+
try {
38+
r = await K.resolve(specifier, context, nextResolve);
39+
} catch (err_) {
40+
const err = new Error(`${err_} when resolving ${specifier} in ${context.parentURL}`);
41+
err.cause = err_;
42+
throw err;
43+
}
44+
3745
try {
3846
const u = new URL(r.url);
3947
if (u.protocol === "file:") {

0 commit comments

Comments
 (0)