Fix layer path resolution#209
Merged
GrahamCampbell merged 1 commit intomainfrom Apr 29, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes layer packaging path resolution so layer file paths are resolved relative to serverless.serviceDir (service root) rather than process.cwd(), and adds a regression test to ensure correctness when the current working directory differs from the service directory.
Changes:
- Resolve
layerObject.pathagainstserverless.serviceDirinpackageLayer()and use that resolved path consistently for zipping inputs/prefix. - Add a unit test that changes
process.cwd()to validatepackageLayer()still resolves layer files relative toserviceDir.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/plugins/package/lib/package-service.js |
Adjusts packageLayer() to compute an absolute layerPath from serviceDir and use it for file path construction and zip prefixing. |
test/unit/lib/plugins/package/lib/package-service.test.js |
Adds regression coverage ensuring layer packaging is independent of process.cwd(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves layer package paths relative to
serverless.serviceDirinstead ofprocess.cwd().This cwd dependency was introduced in 3093c83 when layer packaging started pre-resolving
layerObject.pathwithpath.resolve(...)to support paths like./layerand trailing slash variants. That made packaging sensitive to the shell cwd whenevercwd !== serviceDir.The fix anchors the layer path once with
serverless.serviceDirand uses that same path for both file resolution and ZIP prefix stripping.Adds a regression test for
packageLayer()with a different current working directory.