Skip to content

Commit

Permalink
Merge pull request #92 from larsewi/remove
Browse files Browse the repository at this point in the history
CFE-3896: cfbs remove now automatically prepends ./ if necessary
  • Loading branch information
olehermanse authored Jan 25, 2022
2 parents fa02213 + c1d2f7a commit 62df0d6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ def remove_command(to_remove: list, non_interactive=False):
modules = definition["build"]

def _get_module_by_name(name) -> dict:
if not name.startswith("./") and name.endswith(".cf") and os.path.exists(name):
name = "./" + name

for module in modules:
if module["name"] == name:
return module
Expand Down
35 changes: 35 additions & 0 deletions test/shell/012_prepend_dot_slash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
set -e
set -x
cd test
mkdir -p ./tmp/
cd ./tmp/

echo '
bundle agent test_bundle
{
meta:
"tags" slist => { "autorun" };
reports:
"test";
}
' > test_policy.cf

touch cfbs.json && rm cfbs.json
cfbs init
cfbs add ./test_policy.cf
cfbs remove ./test_policy.cf --non-interactive

rm cfbs.json
cfbs init
cfbs add test_policy.cf
cfbs remove test_policy.cf --non-interactive

rm cfbs.json
cfbs init
cfbs add ./test_policy.cf
cfbs remove test_policy.cf --non-interactive

rm cfbs.json
cfbs init
cfbs add test_policy.cf
cfbs remove ./test_policy.cf --non-interactive
1 change: 1 addition & 0 deletions test/shell/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ bash test/shell/008_remove.sh
bash test/shell/009_clean.sh
bash test/shell/010_local_add.sh
bash test/shell/011_update.sh
bash test/shell/012_prepend_dot_slash.sh

0 comments on commit 62df0d6

Please sign in to comment.