@@ -3,7 +3,7 @@ const _ = require("lodash");
33const BbPromise = require ( "bluebird" ) ;
44const AWS = require ( "aws-sdk" ) ;
55const dynamodbLocal = require ( "dynamodb-localhost" ) ;
6- const { writeSeeds , locateSeeds } = require ( "./src/seeder" ) ;
6+ const seeder = require ( "./src/seeder" ) ;
77
88class ServerlessDynamodbLocal {
99 constructor ( serverless , options ) {
@@ -95,7 +95,7 @@ class ServerlessDynamodbLocal {
9595 }
9696
9797 dynamodbOptions ( ) {
98- const { config } = this ;
98+ const config = this . config ;
9999 const port = _ . get ( config , "start.port" , 8000 ) ;
100100 const dynamoOptions = {
101101 endpoint : `http://localhost:${ port } ` ,
@@ -112,19 +112,19 @@ class ServerlessDynamodbLocal {
112112
113113 migrateHandler ( ) {
114114 const dynamodb = this . dynamodbOptions ( ) ;
115- const { tables } = this ;
115+ const tables = this . tables ;
116116 return BbPromise . each ( tables , ( table ) => this . createTable ( dynamodb , table ) ) ;
117117 }
118118
119119 seedHandler ( ) {
120- const { doc : documentClient } = this . dynamodbOptions ( ) ;
121- const { seedSources } = this ;
120+ const documentClient = this . dynamodbOptions ( ) . doc ;
121+ const seedSources = this . seedSources ;
122122 return BbPromise . each ( seedSources , ( source ) => {
123123 if ( ! source . table ) {
124124 throw new Error ( "seeding source \"table\" property not defined" ) ;
125125 }
126- return locateSeeds ( source . sources || [ ] )
127- . then ( ( seeds ) => writeSeeds ( documentClient , source . table , seeds ) ) ;
126+ return seeder . locateSeeds ( source . sources || [ ] )
127+ . then ( ( seeds ) => seeder . writeSeeds ( documentClient , source . table , seeds ) ) ;
128128 } ) ;
129129 }
130130
@@ -133,12 +133,12 @@ class ServerlessDynamodbLocal {
133133 }
134134
135135 installHandler ( ) {
136- const { options } = this ;
136+ const options = this . options ;
137137 return new BbPromise ( ( resolve ) => dynamodbLocal . install ( resolve , options . localPath ) ) ;
138138 }
139139
140140 startHandler ( ) {
141- const { config } = this ;
141+ const config = this . config ;
142142 const options = _ . merge ( {
143143 sharedDb : this . options . sharedDb || true
144144 } ,
@@ -172,7 +172,7 @@ class ServerlessDynamodbLocal {
172172 get seedSources ( ) {
173173 const config = this . service . custom . dynamodb ;
174174 const seedConfig = _ . get ( config , "seed" , { } ) ;
175- const { seed } = this . options ;
175+ const seed = this . options . seed ;
176176 if ( ! seed ) {
177177 console . log ( "No seed option defined. Cannot seed data." ) ;
178178 return [ ] ;
0 commit comments