Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 87d4a4e

Browse files
committed
Recursive Copy
1 parent 012b55f commit 87d4a4e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,16 @@ zipinfo .serverless/xxx.zip
527527

528528
If you can't see the library, you might need to adjust your package include/exclude configuration in `serverless.yml`.
529529

530+
If you would like to recursively include a directory and all of its contents,
531+
prepend `-r ` to the file list member:
532+
533+
```yaml
534+
custom:
535+
pythonRequirements:
536+
dockerExtraFiles:
537+
- -r /path/to/additional/dependencies/
538+
```
539+
530540
## Optimising packaging time
531541

532542
If you wish to exclude most of the files in your project, and only include the source files of your lambdas and their dependencies you may well use an approach like this:

lib/pip.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,13 @@ async function installRequirements(targetFolder, pluginInstance) {
339339
}
340340

341341
for (let path of options.dockerExtraFiles) {
342-
pipCmds.push(['cp', path, '/var/task/']);
342+
let cmd = ['cp', path, '/var/task/'];
343+
// Copy recursively if -r option was specified
344+
if (path.startsWith('-r ')) {
345+
path = path.split(' ')[1];
346+
cmd = ['cp', '-r', path, '/var/task/']
347+
}
348+
pipCmds.push(cmd);
343349
}
344350

345351
if (process.platform === 'linux') {

0 commit comments

Comments
 (0)