Skip to content

Create include array for zip step if undefined #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/zip.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fse = require('fs-extra');
const path = require('path');
const _ = require('lodash');
const {zipDirectory} = require('./zipService');
const BbPromise = require('bluebird');

Expand All @@ -13,6 +14,9 @@ function addVendorHelper() {
if (this.options.zip) {
this.serverless.cli.log('Adding Python requirements helper...');

if (!_.get(this.serverless.service, 'package.include'))
_.set(this.serverless.service, ['package', 'include'], []);

this.serverless.service.package.include.push('unzip_requirements.py');

return fse.copyAsync(
Expand Down
7 changes: 7 additions & 0 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,10 @@ teardown() {
unzip .serverless/sls-py-req-test.zip -d puck
! ls puck/hug
}

@test "py3.6 can package flask with zip option and no explicit include" {
sed -i'.bak' -e 's/zip: *false/zip: true/' -e 's/include://' -e 's/^.*handler.py//' serverless.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies here - I spent 15 minutes trying to get the right sed syntax for multiline in one expression before smashing my keyboard and writing the second expression.

sls package
unzip .serverless/sls-py-req-test.zip -d puck
ls puck/.requirements.zip puck/unzip_requirements.py
}