diff --git a/lib/cleanup.js b/lib/cleanup.js index 9664c9bb5..6130f8173 100644 --- a/lib/cleanup.js +++ b/lib/cleanup.js @@ -10,6 +10,7 @@ module.exports = { const keepOutputDirectory = this.keepOutputDirectory; const cli = this.options.verbose ? this.serverless.cli : { log: _.noop }; + const keepOutputDirectory = this.keepOutputDirectory; if (!keepOutputDirectory) { cli.log(`Remove ${webpackOutputPath}`); if (this.serverless.utils.dirExistsSync(webpackOutputPath)) { diff --git a/tests/cleanup.test.js b/tests/cleanup.test.js index dec18893a..027a92d13 100644 --- a/tests/cleanup.test.js +++ b/tests/cleanup.test.js @@ -55,9 +55,7 @@ describe('cleanup', () => { module = _.assign( { serverless, - options: { - verbose: true - }, + options: {}, webpackOutputPath: 'my/Output/Path' }, baseModule diff --git a/tests/packageModules.test.js b/tests/packageModules.test.js index 8ee6323f3..82871d63c 100644 --- a/tests/packageModules.test.js +++ b/tests/packageModules.test.js @@ -74,8 +74,7 @@ describe('packageModules', () => { { serverless, options: {}, - webpackOutputPath: '.webpack', - configuration: new Configuration() + webpackOutputPath: '.webpack' }, baseModule ); @@ -329,54 +328,6 @@ describe('packageModules', () => { module.compileStats = stats; return expect(module.packageModules()).to.be.rejectedWith('Packaging: No files found'); }); - - it('should reject if no files are found because all files are excluded using regex', () => { - module.configuration = new Configuration({ - webpack: { - excludeRegex: /.*/ - } - }); - - // Test data - const stats = { - stats: [ - { - compilation: { - compiler: { - outputPath: '/my/Service/Path/.webpack/service' - } - } - } - ] - }; - const files = ['README.md', 'src/handler1.js', 'src/handler1.js.map', 'src/handler2.js', 'src/handler2.js.map']; - const allFunctions = ['func1', 'func2']; - const func1 = { - handler: 'src/handler1', - events: [] - }; - const func2 = { - handler: 'src/handler2', - events: [] - }; - // Serverless behavior - sandbox.stub(serverless.config, 'servicePath').value('/my/Service/Path'); - getVersionStub.returns('1.18.0'); - getServiceObjectStub.returns({ - name: 'test-service' - }); - getAllFunctionsStub.returns(allFunctions); - getFunctionStub.withArgs('func1').returns(func1); - getFunctionStub.withArgs('func2').returns(func2); - // Mock behavior - globMock.sync.returns(files); - fsMock._streamMock.on.withArgs('open').yields(); - fsMock._streamMock.on.withArgs('close').yields(); - fsMock._statMock.isDirectory.returns(false); - - module.compileStats = stats; - return expect(module.packageModules()).to.be.rejectedWith('Packaging: No files found'); - }); }); describe('with individual packaging', () => {