File tree 10 files changed +64
-41
lines changed
10 files changed +64
-41
lines changed Original file line number Diff line number Diff line change
1
+ node_modules /*
2
+ lib /*
Original file line number Diff line number Diff line change
1
+ {
2
+ "env": {
3
+ "node": true
4
+ },
5
+ "extends": [
6
+ "standard",
7
+ "plugin:import/errors",
8
+ "plugin:import/warnings"
9
+ ]
10
+ }
Original file line number Diff line number Diff line change 6
6
"scripts" : {
7
7
"compile" : " babel -d lib/ src/" ,
8
8
"test" : " ava" ,
9
- "lint" : " standard " ,
9
+ "lint" : " eslint ./ " ,
10
10
"prepublish" : " npm run compile" ,
11
11
"pub" : " np"
12
12
},
38
38
"dependencies" : {
39
39
"archiver" : " ^1.0.0" ,
40
40
"aws-sdk" : " ^2.4.13" ,
41
+ "babel-register" : " ^6.22.0" ,
41
42
"bluebird" : " ^3.4.7" ,
42
43
"chalk" : " ^1.1.3" ,
43
44
"cliui" : " ^3.2.0" ,
62
63
"babel-plugin-transform-object-rest-spread" : " ^6.20.2" ,
63
64
"babel-preset-env" : " ^1.1.8" ,
64
65
"babel-register" : " ^6.18.0" ,
66
+ "eslint" : " ^3.14.1" ,
67
+ "eslint-config-standard" : " ^6.2.1" ,
68
+ "eslint-plugin-import" : " ^2.2.0" ,
69
+ "eslint-plugin-promise" : " ^3.4.0" ,
70
+ "eslint-plugin-standard" : " ^2.0.1" ,
65
71
"np" : " ^2.12.0" ,
66
- "standard" : " ^8.6.0" ,
67
72
"testdouble" : " ^1.10.1"
68
73
},
69
74
"babel" : {
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import * as load from '../util/load'
7
7
8
8
const integration = 'x-amazon-apigateway-integration'
9
9
10
- module . exports = function ( opts ) {
10
+ export default function ( opts ) {
11
11
let accountId = opts . accountId
12
12
let path = opts . path
13
13
let method = opts . method
Original file line number Diff line number Diff line change 1
- import { requireProject } from '../util/require-project'
1
+ import requireProject from '../util/require-project'
2
2
import * as load from '../util/load'
3
3
import build from '../util/build-functions'
4
4
import Promise from 'bluebird'
5
5
import chalk from 'chalk'
6
6
import AWS from 'aws-sdk'
7
7
import mergeWith from 'lodash.mergewith'
8
- import requireUnbuilt from '../util/require-unbuilt'
9
8
10
9
import cliui from 'cliui'
11
10
const ui = cliui ( { width : 80 } )
@@ -54,12 +53,11 @@ function runFunction (opts) {
54
53
55
54
const context = { }
56
55
57
- if ( performBuild ) {
58
- await build ( name , env )
59
- }
56
+ performBuild ? await build ( name , env ) : require ( 'babel-register' )
60
57
61
58
const funcPath = `${ performBuild ? 'dist' : 'functions' } /${ name } /${ fileName } .js`
62
- const func = ( performBuild ? requireProject ( funcPath ) : await requireUnbuilt ( funcPath ) ) [ handler ]
59
+
60
+ const func = requireProject ( funcPath ) [ handler ]
63
61
64
62
if ( typeof func !== 'function' ) {
65
63
return Promise . reject ( new Error ( `Handler function provided is not a function. Please verify that there exists a handler function exported as ${ handler } in dist/${ name } /${ fileName } .js` ) )
Original file line number Diff line number Diff line change 1
1
import path from 'path'
2
2
3
- export function requireProject ( relativePath ) {
3
+ export default function ( relativePath ) {
4
4
return require ( projectPath ( relativePath ) )
5
5
}
6
6
7
- export function projectPath ( relativePath ) {
7
+ function projectPath ( relativePath ) {
8
8
return path . join ( process . cwd ( ) , relativePath )
9
9
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -13,11 +13,9 @@ td.when(load.funcs('*')).thenReturn(funcNames)
13
13
td . when ( load . lambdaConfig ( ) , { ignoreExtraArgs : true } ) . thenReturn ( config )
14
14
td . when ( load . events ( ) , { ignoreExtraArgs : true } ) . thenReturn ( events )
15
15
16
- const projectUtils = td . replace ( '../../src/util/require-project' )
17
- td . when ( projectUtils . requireProject ( td . matchers . contains ( 'events' ) ) ) . thenReturn ( { } )
18
-
19
- const requireUnbuilt = td . replace ( '../../src/util/require-unbuilt' )
20
- td . when ( requireUnbuilt ( td . matchers . anything ( ) ) ) . thenResolve ( lambdaFunc )
16
+ const requireProject = td . replace ( '../../src/util/require-project' )
17
+ td . when ( requireProject ( td . matchers . contains ( 'events' ) ) ) . thenReturn ( { } )
18
+ td . when ( requireProject ( td . matchers . contains ( `functions` ) ) ) . thenReturn ( lambdaFunc )
21
19
22
20
test . before ( ( ) => {
23
21
return require ( '../../src/run/index' ) ( { pattern : '*' , build : false } )
@@ -26,4 +24,3 @@ test.before(() => {
26
24
test ( 'Calls the functions' , ( ) => {
27
25
td . verify ( lambdaFunc [ handler ] ( ) , { times : funcNames . length , ignoreExtraArgs : true } )
28
26
} )
29
-
Original file line number Diff line number Diff line change
1
+ import test from 'ava'
2
+ import td from '../helpers/testdouble'
3
+
4
+ const funcName = 'foo'
5
+ const handler = 'handler'
6
+ const config = { Handler : `index.${ handler } ` }
7
+ const events = [ { } ]
8
+ const lambdaFunc = td . object ( [ handler ] )
9
+ td . when ( lambdaFunc [ handler ] ( td . matchers . anything ( ) , td . matchers . isA ( Object ) ) ) . thenCallback ( null , 'bar' )
10
+
11
+ const load = td . replace ( '../../src/util/load' )
12
+ td . when ( load . funcs ( funcName ) ) . thenReturn ( [ funcName ] )
13
+ td . when ( load . lambdaConfig ( funcName ) ) . thenReturn ( config )
14
+ td . when ( load . events ( funcName , td . matchers . anything ( ) ) ) . thenReturn ( events )
15
+
16
+ const build = td . replace ( '../../src/util/build-functions' )
17
+ td . when ( build ( funcName , td . matchers . anything ( ) ) ) . thenResolve ( { } )
18
+
19
+ const requireProject = td . replace ( '../../src/util/require-project' )
20
+ td . when ( requireProject ( td . matchers . contains ( `dist/${ funcName } ` ) ) ) . thenReturn ( lambdaFunc )
21
+
22
+ test . before ( async ( ) => {
23
+ return await require ( '../../src/run/index' ) ( { pattern : funcName , build : true } )
24
+ } )
25
+
26
+ test ( 'Calls the function' , ( ) => {
27
+ td . verify ( lambdaFunc [ handler ] ( ) , { ignoreExtraArgs : true } )
28
+ } )
29
+
30
+ test ( 'Loads event' , ( ) => {
31
+ td . verify ( requireProject ( td . matchers . contains ( 'events' ) ) )
32
+ } )
Original file line number Diff line number Diff line change @@ -13,10 +13,8 @@ td.when(load.funcs(funcName)).thenReturn([funcName])
13
13
td . when ( load . lambdaConfig ( funcName ) ) . thenReturn ( config )
14
14
td . when ( load . events ( funcName , td . matchers . anything ( ) ) ) . thenReturn ( events )
15
15
16
- const projectUtils = td . replace ( '../../src/util/require-project' )
17
-
18
- const requireUnbuilt = td . replace ( '../../src/util/require-unbuilt' )
19
- td . when ( requireUnbuilt ( td . matchers . contains ( funcName ) ) ) . thenResolve ( lambdaFunc )
16
+ const requireProject = td . replace ( '../../src/util/require-project' )
17
+ td . when ( requireProject ( td . matchers . contains ( `functions/${ funcName } ` ) ) ) . thenReturn ( lambdaFunc )
20
18
21
19
test . before ( async ( ) => {
22
20
return await require ( '../../src/run/index' ) ( { pattern : funcName , build : false } )
@@ -27,6 +25,5 @@ test('Calls the function', () => {
27
25
} )
28
26
29
27
test ( 'Loads event' , ( ) => {
30
- td . verify ( projectUtils . requireProject ( td . matchers . contains ( 'events' ) ) )
28
+ td . verify ( requireProject ( td . matchers . contains ( 'events' ) ) )
31
29
} )
32
-
You can’t perform that action at this time.
0 commit comments