Skip to content

Commit 8ebddc8

Browse files
committed
feat: Print 'operating in local directory' when in local mode
This is a convenience because some commands may not output anything (ex. list) under certain valid conditions. This warning helps orient the user if a different command was intended
1 parent c5317f5 commit 8ebddc8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pkg/lib/util/util.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ util.setup_mode() {
269269
if [ "$BPM_IS_LOCAL" = yes ]; then
270270
local project_root_dir=
271271
if project_root_dir="$(util.get_project_root_dir)"; then
272+
# Output to standard error because some subcommands may be scriptable (ex. list)
273+
log.info "Operating in local directory" >&2
274+
272275
BPM_ROOT="$project_root_dir"
273276
BPM_PREFIX="$project_root_dir/bpm_packages"
274277
BPM_PACKAGES_PATH="$BPM_PREFIX/packages"

tests/mode-global.bats

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
load 'util/init.sh'
44

5+
@test "print operating in local dir if not in global mode" {
6+
touch 'bpm.toml'
7+
8+
run bpm echo "PWD"
9+
assert_success
10+
assert_output -p "Operating in local directory"
11+
}
12+
513
# We only test two of all commands
614
@test "error when not passing --global to add, list, and upgrade" {
715
local str="No 'bpm.toml' file found"
@@ -24,19 +32,17 @@ load 'util/init.sh'
2432

2533
run bpm list
2634
assert_success
27-
assert_output ""
2835
}
2936

3037
@test "do not error when not passing --global to echo, complete, and init" {
3138
touch 'bpm.toml'
3239

3340
run bpm echo "PWD"
3441
assert_success
35-
assert_output "$PWD"
42+
assert_line -n 1 "$PWD"
3643

3744
run bpm complete package-path
3845
assert_success
39-
assert_output ""
4046

4147
run bpm init bash
4248
assert_success

0 commit comments

Comments
 (0)