Skip to content

Commit d656aae

Browse files
committed
feat: Enable 'local' installation mode. Closes #12
'local' installation mode requires the presense of a 'bpm.toml' file. This is to determine the root of the project (so we know where to place the 'bpm_packages' folder)
1 parent 532e20c commit d656aae

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

pkg/completions/bpm.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
_bpm() {
2-
local -ra listPreSubcommandOptions=(--help --version)
2+
local -ra listPreSubcommandOptions=(--help --version --global)
33
local -ra listSubcommands=(add echo init link list package-path remove upgrade)
44

55
local -r currentWord="${COMP_WORDS[COMP_CWORD]}"

pkg/lib/cmd/bpm.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ main() {
1515
source "$f"
1616
done
1717

18+
local is_global='no'
19+
1820
for arg; do
1921
case "$arg" in
2022
--help)
@@ -28,14 +30,37 @@ main() {
2830
exit
2931
;;
3032
--global)
31-
declare -rg BPM_MODE_GLOBAL=
33+
is_global='yes'
34+
shift
3235
;;
3336
*)
3437
break
3538
;;
3639
esac
3740
done
3841

42+
if [ "$is_global" = 'no' ]; then
43+
if ! project_root_directory="$(
44+
while [[ ! -f "bpm.toml" && "$PWD" != / ]]; do
45+
cd ..
46+
done
47+
48+
if [[ $PWD == / ]]; then
49+
die "No 'bpm.toml' file found. Please create one to install local packages or pass the '--global' option"
50+
fi
51+
52+
printf "%s" "$PWD"
53+
)"; then
54+
exit 1
55+
fi
56+
57+
BPM_PREFIX="$project_root_directory/bpm_packages"
58+
BPM_PACKAGES_PATH="$BPM_PREFIX/packages"
59+
BPM_INSTALL_BIN="$BPM_PREFIX/bin"
60+
BPM_INSTALL_MAN="$BPM_PREFIX/man"
61+
BPM_INSTALL_COMPLETIONS="$BPM_PREFIX/completions"
62+
fi
63+
3964
case "$1" in
4065
add)
4166
shift

pkg/lib/commands/do-plumbing-remove-deps.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ do-plumbing-remove-deps() {
2020
fi
2121
fi
2222

23-
# TODO: bug: this removes dependencies specified with incorrect URLs
2423
log.info "Removing dependencies for '$package'"
2524
for dep in "${deps[@]}"; do
2625
util.construct_clone_url "$repoSpec" "$with_ssh"
27-
local uri="$REPLY1"
2826
local site="$REPY2"
2927
local package="$REPLY3"
3028
local ref="$REPLY4"
3129

32-
rm -rf "${BPM_PACKAGES_PATH:?}/$package"
30+
rm -rf "${BPM_PACKAGES_PATH:?}/$site/$package"
3331
done
3432
}

tests/do-plumbing-remove-deps.bats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bats
2+
3+
# TODO

0 commit comments

Comments
 (0)