Skip to content

test: add tests for bash-file-extract utility #57

@George-iam

Description

@George-iam

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstestingTest improvements and coverage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions