@brickhouse-tech/sync-agents 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sh/sync-agents.sh +22 -8
package/package.json
CHANGED
package/src/sh/sync-agents.sh
CHANGED
|
@@ -3,17 +3,31 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
AGENTS_DIR=".agents"
|
|
5
5
|
AGENTS_MD="AGENTS.md"
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
# Resolve the real script directory, following symlinks.
|
|
8
|
+
# Needed for `npm i -g` installs where the executable is a symlink in PATH
|
|
9
|
+
# (e.g. /usr/local/bin/sync-agents -> .../node_modules/.../src/sh/sync-agents.sh).
|
|
10
|
+
# BSD readlink (macOS default) lacks -f, so we walk the chain ourselves.
|
|
11
|
+
resolve_script_dir() {
|
|
12
|
+
local path="${BASH_SOURCE[0]}"
|
|
13
|
+
while [[ -L "$path" ]]; do
|
|
14
|
+
local dir
|
|
15
|
+
dir="$(cd -P "$(dirname "$path")" && pwd)"
|
|
16
|
+
path="$(readlink "$path")"
|
|
17
|
+
[[ "$path" != /* ]] && path="$dir/$path"
|
|
18
|
+
done
|
|
19
|
+
cd -P "$(dirname "$path")" && pwd
|
|
20
|
+
}
|
|
21
|
+
SCRIPT_DIR="$(resolve_script_dir)"
|
|
7
22
|
PACKAGE_JSON="${SCRIPT_DIR}/../../package.json"
|
|
8
23
|
TEMPLATES_DIR="${SCRIPT_DIR}/../md"
|
|
9
24
|
|
|
10
|
-
# Pull version from package.json
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
VERSION="$(node -p "require('@brickhouse-tech/sync-agents/package.json').version" 2>/dev/null || echo "unknown")"
|
|
25
|
+
# Pull version from package.json via node (we're an npm package, node is present).
|
|
26
|
+
# Force CommonJS so this works regardless of the caller's ESM/CJS context
|
|
27
|
+
# (e.g. NODE_OPTIONS=--input-type=module). Path is passed via argv to avoid
|
|
28
|
+
# shell-quoting issues. Requires Node 20+.
|
|
29
|
+
if [[ -f "$PACKAGE_JSON" ]] && command -v node >/dev/null 2>&1; then
|
|
30
|
+
VERSION="$(node --input-type=commonjs -e 'process.stdout.write(require(process.argv[1]).version)' "$PACKAGE_JSON" 2>/dev/null || echo unknown)"
|
|
17
31
|
else
|
|
18
32
|
VERSION="unknown"
|
|
19
33
|
fi
|