The bash file extraction utility (src/utils/bash-file-extract.ts) parses bash commands to extract file paths that a command writes to (redirects, tee, sed -i, cp, mv, rm, touch, etc.). While the existing test suite covers some related functionality, the extractBashWritePaths function itself could use more edge-case coverage. It is a pure function that takes a command string and returns an array of paths, making it straightforward to test.
Relevant files:
src/utils/bash-file-extract.ts — the module to test (exports extractBashWritePaths)
test/ — place the new test file here as bash-file-extract.test.ts
Suggested test cases:
- Simple redirect:
echo hello > out.txt
- Append redirect:
echo hello >> log.txt
- Stderr redirect:
cmd 2> error.log
- Combined redirect:
cmd &> all.log
- Tee:
cmd | tee output.txt
- Tee with -a flag:
cmd | tee -a output.txt
- Compound commands:
echo a > x.txt && echo b > y.txt
- Filtering of pseudo-paths:
/dev/null, -, $VAR
- cp/mv destination extraction
- Quoted paths:
echo hello > "my file.txt"
- No false positives from plain commands:
ls -la, echo hello
Acceptance criteria:
- New file
test/bash-file-extract.test.ts with at least 12 tests
- All tests pass with
npm test
The bash file extraction utility (
src/utils/bash-file-extract.ts) parses bash commands to extract file paths that a command writes to (redirects, tee, sed -i, cp, mv, rm, touch, etc.). While the existing test suite covers some related functionality, theextractBashWritePathsfunction itself could use more edge-case coverage. It is a pure function that takes a command string and returns an array of paths, making it straightforward to test.Relevant files:
src/utils/bash-file-extract.ts— the module to test (exportsextractBashWritePaths)test/— place the new test file here asbash-file-extract.test.tsSuggested test cases:
echo hello > out.txtecho hello >> log.txtcmd 2> error.logcmd &> all.logcmd | tee output.txtcmd | tee -a output.txtecho a > x.txt && echo b > y.txt/dev/null,-,$VARecho hello > "my file.txt"ls -la,echo helloAcceptance criteria:
test/bash-file-extract.test.tswith at least 12 testsnpm test