diff --git a/src/lib/service.js b/src/lib/service.js index 02ededf..0eeb902 100644 --- a/src/lib/service.js +++ b/src/lib/service.js @@ -6,6 +6,7 @@ const makeAllRelative = p => R.when(R.has(p), R.over(R.lensProp(p), R.map(makeRe const makePackageRelative = R.compose(makeAllRelative('include'), makeAllRelative('exclude')); const setPackage = R.pipe( + R.defaultTo({}), makePackageRelative, R.over(R.lensProp('exclude'), R.append('**')), R.assoc('individually', true) @@ -15,7 +16,7 @@ const fnPath = R.compose(R.replace(/\.[^.]+$/, '.js'), R.prop('handler')); const setFnsPackage = R.map( R.pipe( - R.over(R.lensProp('package'), makePackageRelative), + R.when(R.has('package'), R.over(R.lensProp('package'), makePackageRelative)), R.converge( R.over(R.lensPath(['package', 'include'])), [R.compose(R.append, fnPath), R.identity] diff --git a/test/fns.js b/test/fns.js index e3c6d22..db6a1c4 100644 --- a/test/fns.js +++ b/test/fns.js @@ -8,10 +8,6 @@ const originalFns = { }, secondGet: { handler: 'functions/second/get.handler', - package: { - include: ['node_modules/**'], - exclude: ['abc.js'], - }, }, post: { handler: 'functions/post.handler', diff --git a/test/service.test.js b/test/service.test.js index ac0b139..aadf113 100644 --- a/test/service.test.js +++ b/test/service.test.js @@ -2,12 +2,12 @@ const path = require('path'); const service = require('../src/lib/service'); const fns = require('./fns.js'); -test('service package when no package', () => { +test('service package when package is undefined', () => { const expectedPackage = { individually: true, exclude: ['**'], }; - expect(service.setPackage({})).toEqual(expectedPackage); + expect(service.setPackage(undefined)).toEqual(expectedPackage); }); test('service package with existing package and no include/exclude', () => { @@ -51,8 +51,7 @@ test('setFnsPackage', () => { secondGet: { handler: 'functions/second/get.handler', package: { - include: ['../node_modules/**', 'functions/second/get.js'], - exclude: ['../abc.js'], + include: ['functions/second/get.js'], }, }, post: {