Skip to content

Commit d2a0ccf

Browse files
committed
refactor: Rename 'BPM_IS_LOCAL' to 'BPM_MODE'
1 parent 847d2dd commit d2a0ccf

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

pkg/lib/cmd/bpm.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ main() {
1515
source "$f"
1616
done
1717

18-
BPM_IS_LOCAL='yes'
18+
BPM_MODE='local'
1919

2020
for arg; do
2121
case "$arg" in
@@ -30,7 +30,7 @@ main() {
3030
exit
3131
;;
3232
--global|-g)
33-
BPM_IS_LOCAL='no'
33+
BPM_MODE='global'
3434
shift
3535
;;
3636
*)

pkg/lib/commands/do-add.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ do-add() {
3636
die "No packages may be supplied when using '--all'"
3737
fi
3838

39-
if [ "$BPM_IS_LOCAL" = yes ] && (( ${#pkgs[@]} > 0 )); then
39+
if [ "$BPM_MODE" = local ] && (( ${#pkgs[@]} > 0 )); then
4040
die "Cannot specify individual packages for subcommand 'add' in local projects. Please edit your 'bpm.toml' and use either 'add --all' or 'remove --all'"
4141
fi
4242

43-
if [[ "$BPM_IS_LOCAL" == no && "$flag_all" == yes ]]; then
43+
if [[ "$BPM_MODE" == global && "$flag_all" == yes ]]; then
4444
die "Cannot pass '--all' without a 'bpm.toml' file"
4545
fi
4646

@@ -89,7 +89,7 @@ do-actual-add() {
8989
fi
9090

9191
if [ -e "$BPM_PACKAGES_PATH/$site/$package" ]; then
92-
if [ "$BPM_IS_LOCAL" = yes ]; then
92+
if [ "$BPM_MODE" = local ]; then
9393
log.info "Skipping '$site/$package' as it's already present"
9494
return
9595
else

pkg/lib/commands/do-remove.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ do-remove() {
2828
die "No packages may be supplied when using '--all'"
2929
fi
3030

31-
if [ "$BPM_IS_LOCAL" = yes ] && (( ${#pkgs[@]} > 0 )); then
31+
if [ "$BPM_MODE" = local ] && (( ${#pkgs[@]} > 0 )); then
3232
die "Cannot specify individual packages for subcommand 'remove' in local projects. Please edit your 'bpm.toml' and use either 'add --all' or 'remove --all'"
3333
fi
3434

pkg/lib/commands/do-upgrade.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ do-upgrade() {
2828
die "No packages may be supplied when using '--all'"
2929
fi
3030

31-
if [ "$BPM_IS_LOCAL" = yes ] && (( ${#pkgs[@]} > 0 )); then
31+
if [ "$BPM_MODE" = local ] && (( ${#pkgs[@]} > 0 )); then
3232
die "Cannot specify individual packages for subcommand 'upgrade' in local projects. Please edit your 'bpm.toml' and use either 'add --all' or 'remove --all'"
3333
fi
3434

3535
if [[ $upgrade_bpm == yes && "$flag_all" = yes ]]; then
3636
die "Upgrading bpm and using '--all' are mutually exclusive behaviors"
3737
fi
3838

39-
if [[ $upgrade_bpm == yes && "$BPM_IS_LOCAL" == yes ]]; then
39+
if [[ $upgrade_bpm == yes && "$BPM_MODE" == local ]]; then
4040
die "Cannot upgrade bpm with a local 'bpm.toml' file"
4141
fi
4242

pkg/lib/util/util.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ util.get_project_root_dir() {
268268

269269
# @description Sets up the variables for the current mode
270270
util.setup_mode() {
271-
if [ "$BPM_IS_LOCAL" = yes ]; then
271+
if [ "$BPM_MODE" = local ]; then
272272
local project_root_dir=
273273
if project_root_dir="$(util.get_project_root_dir)"; then
274274
# Output to standard error because some subcommands may be scriptable (ex. list)

tests/do-add.bats

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ load 'util/init.sh'
215215
test_util.create_package "$pkg2"
216216

217217
echo "dependencies = [ 'file://$BPM_ORIGIN_DIR/$pkg', 'file://$BPM_ORIGIN_DIR/$pkg2' ]" > 'bpm.toml'
218-
BPM_IS_LOCAL='yes' run do-add --all
218+
BPM_MODE='local' run do-add --all
219219

220220
assert_success
221221

@@ -239,7 +239,7 @@ load 'util/init.sh'
239239
cd "$BPM_CWD"
240240

241241
echo "dependencies = [ 'file://$BPM_ORIGIN_DIR/$pkg', 'file://$BPM_ORIGIN_DIR/$pkg2' ]" > 'bpm.toml'
242-
BPM_IS_LOCAL='yes' run do-add --all
242+
BPM_MODE='local' run do-add --all
243243

244244
assert_success
245245
assert [ -d "./bpm_packages/packages/$site/$pkg/.git" ]
@@ -258,7 +258,7 @@ load 'util/init.sh'
258258
cd "$BPM_CWD"
259259

260260
echo "dependencies = [ 'file://$BPM_ORIGIN_DIR/$pkg1@v0.1.0' ]" > 'bpm.toml'
261-
BPM_IS_LOCAL='yes' run do-add --all
261+
BPM_MODE='local' run do-add --all
262262

263263
assert_success
264264
assert [ -d "./bpm_packages/packages/$site/$pkg1" ]
@@ -277,7 +277,7 @@ load 'util/init.sh'
277277
cd "$BPM_CWD"
278278

279279
echo "dependencies = [ 'file://$BPM_ORIGIN_DIR/$pkg1@v0.1.0' ]" > 'bpm.toml'
280-
BPM_IS_LOCAL='yes' run do-add --all
280+
BPM_MODE='local' run do-add --all
281281

282282
assert_success
283283
assert [ -d "./bpm_packages/packages/$site/$pkg1" ]
@@ -288,7 +288,7 @@ load 'util/init.sh'
288288
@test "--all prints warning when no dependencies are specified in bpm.toml" {
289289
touch 'bpm.toml'
290290

291-
BPM_IS_LOCAL='yes' run do-add --all
291+
BPM_MODE='local' run do-add --all
292292

293293
assert_success
294294
assert_line -p "No dependencies specified in 'dependencies' key"
@@ -298,7 +298,7 @@ load 'util/init.sh'
298298
@test "--all errors when a package is specified as argument" {
299299
touch 'bpm.toml'
300300

301-
BPM_IS_LOCAL='yes' run do-add --all pkg
301+
BPM_MODE='local' run do-add --all pkg
302302

303303
assert_failure
304304
assert_line -p "No packages may be supplied when using '--all'"
@@ -320,12 +320,12 @@ load 'util/init.sh'
320320
test_util.create_package "$pkg2"
321321

322322
echo "dependencies = [ 'file://$BPM_ORIGIN_DIR/$pkg1' ]" > 'bpm.toml'
323-
BPM_IS_LOCAL='yes' run do-add --all
323+
BPM_MODE='local' run do-add --all
324324

325325
assert_success
326326

327327
echo "dependencies = [ 'file://$BPM_ORIGIN_DIR/$pkg1', 'file://$BPM_ORIGIN_DIR/$pkg2' ]" > 'bpm.toml'
328-
BPM_IS_LOCAL='yes' run do-add --all
328+
BPM_MODE='local' run do-add --all
329329

330330
assert_success
331331
assert [ -d "./bpm_packages/packages/$site/$pkg1" ]
@@ -342,7 +342,7 @@ load 'util/init.sh'
342342

343343
test_util.create_package "$pkg1"
344344

345-
BPM_IS_LOCAL='yes' run do-add "$pkg1"
345+
BPM_MODE='local' run do-add "$pkg1"
346346

347347
assert_failure
348348
assert_line -p "Cannot specify individual packages for subcommand 'add' in local projects. Please edit your 'bpm.toml' and use either 'add --all' or 'remove --all'"

tests/do-remove.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ load 'util/init.sh'
252252

253253
test_util.create_package "$pkg1"
254254

255-
BPM_IS_LOCAL='yes' run do-remove "$pkg1"
255+
BPM_MODE='local' run do-remove "$pkg1"
256256

257257
assert_failure
258258
assert_line -p "Cannot specify individual packages for subcommand 'remove' in local projects. Please edit your 'bpm.toml' and use either 'add --all' or 'remove --all'"

tests/do-upgrade.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ load 'util/init.sh'
193193
@test "fail if bpm is specified in local mode" {
194194
touch 'bpm.toml'
195195

196-
BPM_IS_LOCAL='yes' run do-upgrade bpm
196+
BPM_MODE='local' run do-upgrade bpm
197197

198198
assert_failure
199199
assert_line -p "Cannot upgrade bpm with a local 'bpm.toml' file"
@@ -216,7 +216,7 @@ load 'util/init.sh'
216216

217217
test_util.create_package "$pkg1"
218218

219-
BPM_IS_LOCAL='yes' run do-upgrade "$pkg1"
219+
BPM_MODE='local' run do-upgrade "$pkg1"
220220

221221
assert_failure
222222
assert_line -p "Cannot specify individual packages for subcommand 'upgrade' in local projects. Please edit your 'bpm.toml' and use either 'add --all' or 'remove --all'"

tests/util/init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export BPM_TEST_DIR="$BATS_TMPDIR/bpm"
1717
export BPM_CWD="$BPM_TEST_DIR/cwd"
1818
export BPM_ORIGIN_DIR="$BPM_TEST_DIR/origin"
1919
export BPM_MODE_TEST=
20-
export BPM_IS_LOCAL='no' # normal default is 'yes'
20+
export BPM_MODE='global' # normal default is 'local'
2121

2222
# Stub common variables
2323
test_util.get_bpm_root

0 commit comments

Comments
 (0)