Skip to content

Prevent serverless package hash from changing #394

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 2 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions lib/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ function injectRequirements(requirementsPath, packagePath, options) {
.map(([file, relativeFile]) =>
Promise.all([file, relativeFile, fse.statAsync(file)])
)
.map(([file, relativeFile, fileStat]) =>
.mapSeries(([file, relativeFile, fileStat]) =>
zipFile(zip, relativeFile, fse.readFileAsync(file), {
unixPermissions: fileStat.mode
unixPermissions: fileStat.mode,
createFolders: false
})
)
.then(() => writeZip(zip, packagePath))
Expand Down
12 changes: 12 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const crossSpawn = require('cross-spawn');
const deasync = require('deasync-promise');
const glob = require('glob-all');
const JSZip = require('jszip');
const sha256File = require('sha256-file');
const tape = require('tape');
const {
chmodSync,
Expand Down Expand Up @@ -132,6 +133,17 @@ test('default pythonBin can package flask with default options', t => {
t.end();
});

test('py3.6 packages have the same hash', t => {
process.chdir('tests/base');
const path = npm(['pack', '../..']);
npm(['i', path]);
sls(['package']);
const fileHash = sha256File('.serverless/sls-py-req-test.zip');
sls(['package']);
t.equal(sha256File('.serverless/sls-py-req-test.zip'), fileHash, 'packages have the same hash');
t.end();
});

test('py3.6 can package flask with default options', t => {
process.chdir('tests/base');
const path = npm(['pack', '../..']);
Expand Down