diff --git a/lib/validate.js b/lib/validate.js index 061d49e1b..fb97fc96c 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -96,8 +96,12 @@ module.exports = { _.merge(entries, entry); } else { _.forEach(functions, (func, index) => { - const entry = getEntryForFunction.call(this, functions[index], this.serverless.service.getFunction(func)); - _.merge(entries, entry); + const loadedFunc = this.serverless.service.getFunction(func); + const runtime = loadedFunc.runtime || this.serverless.service.provider.runtime; + if (runtime.match(/^node/)) { + const entry = getEntryForFunction.call(this, functions[index], loadedFunc); + _.merge(entries, entry); + } }); } diff --git a/tests/validate.test.js b/tests/validate.test.js index ce2045ed6..4416c0b77 100644 --- a/tests/validate.test.js +++ b/tests/validate.test.js @@ -422,7 +422,8 @@ describe('validate', () => { path: 'func1path' } } - ] + ], + runtime: 'node10.x' }, func2: { handler: 'module2.func2handler', @@ -437,7 +438,8 @@ describe('validate', () => { { nonhttp: 'non-http' } - ] + ], + runtime: 'node10.x' }, func3: { handler: 'handlers/func3/module2.func3handler', @@ -446,7 +448,8 @@ describe('validate', () => { { nonhttp: 'non-http' } - ] + ], + runtime: 'node10.x' }, func4: { handler: 'handlers/module2/func3/module2.func3handler', @@ -455,7 +458,18 @@ describe('validate', () => { { nonhttp: 'non-http' } - ] + ], + runtime: 'node10.x' + }, + func5: { + handler: 'com.serverless.Handler', + artifact: 'target/hello-dev.jar', + events: [ + { + nonhttp: 'non-http' + } + ], + runtime: 'java8' } }; @@ -469,19 +483,24 @@ describe('validate', () => { path: 'func1path' } } - ] + ], + runtime: 'node10.x' } }; - it('should expose all functions if `options.function` is not defined', () => { + it('should expose all node functions if `options.function` is not defined', () => { const testOutPath = 'test'; const testConfig = { entry: 'test', context: 'testcontext', output: { path: testOutPath + }, + getFunction: func => { + return testFunctionsConfig[func]; } }; + _.set(module.serverless.service, 'custom.webpack.config', testConfig); module.serverless.service.functions = testFunctionsConfig; globSyncStub.callsFake(filename => [_.replace(filename, '*', 'js')]);