Skip to content
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

Display the zip method used #735

Merged
merged 3 commits into from
Mar 18, 2021
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
4 changes: 2 additions & 2 deletions lib/packageModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const BbPromise = require('bluebird');
const _ = require('lodash');
const path = require('path');
const bestzip = require('bestzip');
const { bestzip, hasNativeZip } = require('bestzip');
const glob = require('glob');
const semver = require('semver');
const fs = require('fs');
Expand Down Expand Up @@ -118,7 +118,7 @@ module.exports = {
() =>
this.options.verbose &&
this.serverless.cli.log(
`Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} [${_.now() - startZip} ms]`
`Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'} (using ${hasNativeZip() ? 'native' : 'node'} method): ${modulePath} [${_.now() - startZip} ms]`
)
);
});
Expand Down
72 changes: 15 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions tests/mocks/bestzip.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const sinon = require('sinon');
const BestZipMock = sandbox => sandbox.stub();

module.exports.create = sandbox => {
const bestzipMock = BestZipMock(sandbox);
const mock = sinon.stub().resolves(bestzipMock);
return mock;
return {
bestzip: sinon.stub().resolves(BestZipMock(sandbox)),
hasNativeZip: sandbox.stub().returns(false),
};
};
4 changes: 1 addition & 3 deletions tests/mocks/child_process.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
*/

module.exports.create = sandbox => {
const childProcessMock = {
return {
exec: sandbox.stub().yields(),
spawn: sandbox.stub().returns(/* child process object */),
execSync: sandbox.stub().returns('{}')
};

return childProcessMock;
};
4 changes: 1 addition & 3 deletions tests/mocks/fs-extra.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
*/

module.exports.create = sandbox => {
const fsExtraMock = {
return {
copy: sandbox.stub().yields(),
pathExists: sandbox.stub().yields(),
pathExistsSync: sandbox.stub().returns(false),
removeSync: sandbox.stub()
};

return fsExtraMock;
};
5 changes: 2 additions & 3 deletions tests/mocks/fs.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const StatMock = sandbox => ({
module.exports.create = sandbox => {
const streamMock = StreamMock(sandbox);
const statMock = StatMock(sandbox);
const fsMock = {

return {
createWriteStream: sinon.stub().returns(streamMock), // Persistent stub
readFileSync: sandbox.stub(),
statSync: sinon.stub().returns(statMock), // Persistent stub
Expand All @@ -28,6 +29,4 @@ module.exports.create = sandbox => {
_streamMock: streamMock,
_statMock: statMock
};

return fsMock;
};
4 changes: 2 additions & 2 deletions tests/packageModules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('packageModules', () => {
module.compileStats = { stats: [] };
return expect(module.packageModules()).to.be.fulfilled.then(() =>
BbPromise.all([
expect(bestzipMock).to.not.have.been.called,
expect(bestzipMock.bestzip).to.not.have.been.called,
expect(writeFileDirStub).to.not.have.been.called,
expect(fsMock.createWriteStream).to.not.have.been.called,
expect(globMock.sync).to.not.have.been.called
Expand All @@ -104,7 +104,7 @@ describe('packageModules', () => {
module.skipCompile = true;
return expect(module.packageModules()).to.be.fulfilled.then(() =>
BbPromise.all([
expect(bestzipMock).to.not.have.been.called,
expect(bestzipMock.bestzip).to.not.have.been.called,
expect(writeFileDirStub).to.not.have.been.called,
expect(fsMock.createWriteStream).to.not.have.been.called,
expect(globMock.sync).to.not.have.been.called
Expand Down