Skip to content

Commit

Permalink
Fix error on missing package (#31)
Browse files Browse the repository at this point in the history
Fixes #30
  • Loading branch information
jogold authored Jul 5, 2017
1 parent 71a860b commit b6aee6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/lib/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand Down
4 changes: 0 additions & 4 deletions test/fns.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ const originalFns = {
},
secondGet: {
handler: 'functions/second/get.handler',
package: {
include: ['node_modules/**'],
exclude: ['abc.js'],
},
},
post: {
handler: 'functions/post.handler',
Expand Down
7 changes: 3 additions & 4 deletions test/service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit b6aee6a

Please sign in to comment.