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

Commit dddea23

Browse files
authored
Prevent serverless package hash from changing (serverless#394)
Prevent serverless package hash from changing
2 parents 7d3e263 + 23b9664 commit dddea23

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/inject.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ function injectRequirements(requirementsPath, packagePath, options) {
3939
.map(([file, relativeFile]) =>
4040
Promise.all([file, relativeFile, fse.statAsync(file)])
4141
)
42-
.map(([file, relativeFile, fileStat]) =>
42+
.mapSeries(([file, relativeFile, fileStat]) =>
4343
zipFile(zip, relativeFile, fse.readFileAsync(file), {
44-
unixPermissions: fileStat.mode
44+
unixPermissions: fileStat.mode,
45+
createFolders: false
4546
})
4647
)
4748
.then(() => writeZip(zip, packagePath))

test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const crossSpawn = require('cross-spawn');
22
const deasync = require('deasync-promise');
33
const glob = require('glob-all');
44
const JSZip = require('jszip');
5+
const sha256File = require('sha256-file');
56
const tape = require('tape');
67
const {
78
chmodSync,
@@ -133,6 +134,17 @@ test('default pythonBin can package flask with default options', t => {
133134
t.end();
134135
});
135136

137+
test('py3.6 packages have the same hash', t => {
138+
process.chdir('tests/base');
139+
const path = npm(['pack', '../..']);
140+
npm(['i', path]);
141+
sls(['package']);
142+
const fileHash = sha256File('.serverless/sls-py-req-test.zip');
143+
sls(['package']);
144+
t.equal(sha256File('.serverless/sls-py-req-test.zip'), fileHash, 'packages have the same hash');
145+
t.end();
146+
});
147+
136148
test('py3.6 can package flask with default options', t => {
137149
process.chdir('tests/base');
138150
const path = npm(['pack', '../..']);

0 commit comments

Comments
 (0)