Skip to content

feat: add stripPrefix config to remove leading path from destination files - #2

Open
rafaio1 wants to merge 1 commit into
mxx1111:mainfrom
rafaio1:feat/strip-prefix
Open

feat: add stripPrefix config to remove leading path from destination files#2
rafaio1 wants to merge 1 commit into
mxx1111:mainfrom
rafaio1:feat/strip-prefix

Conversation

@rafaio1

@rafaio1 rafaio1 commented Aug 18, 2026

Copy link
Copy Markdown

This PR implements the stripPrefix feature as requested in #10.

Changes

  • Added stripPrefix to KNOWN_KEYS and parsed it in src/config.mjs.
  • Modified src/pack.mjs to compute the destination path using stripPrefix after all files are collected.
  • Added validation to throw an error if stripPrefix matches no files in the pack.
  • Added validation to throw an error on destination path collisions (no last-write-wins).
  • Rejected traversal attempts (e.g. .. or absolute paths) in both the config prefix itself and the resulting stripped paths.
  • Updated MANIFEST.json generation to record the post-strip destPath.
  • Updated the sparepack init template in bin/sparepack.mjs to include the new key.
  • Updated README.md to document the new feature.
  • Added comprehensive test suite in test/stripPrefix.test.mjs covering all acceptance criteria.

All 85 tests pass successfully.

…files

- Add stripPrefix key to sparepack.yaml config
- Apply prefix stripping to destination paths only (not source resolution)
- Throw error if prefix matches no files in the pack
- Throw error on destination path collision
- Reject traversal attempts (.. or absolute paths)
- Update MANIFEST.json to record post-strip paths
- Update sparepack init template and README
- Add comprehensive test suite for stripPrefix functionality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant