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

Commit ec15f50

Browse files
committed
prevent file hash from changing
1 parent ded3398 commit ec15f50

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,
@@ -132,6 +133,17 @@ test('default pythonBin can package flask with default options', t => {
132133
t.end();
133134
});
134135

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

0 commit comments

Comments
 (0)