1+ import type { Subprocess } from 'bun'
2+ import type { LaunchOptions } from './types'
13import * as fs from 'node:fs'
24import * as https from 'node:https'
35import * as path from 'node:path'
46import process from 'node:process'
57import { promisify } from 'node:util'
68import * as zlib from 'node:zlib'
7- import type { Subprocess } from 'bun'
89import Debug from 'debug'
910import * as tar from 'tar'
1011import { config } from './config'
11- import type { LaunchOptions } from './types'
1212import { exists } from './utils'
1313
1414const debug = Debug ( 'dynamodb-local' )
@@ -27,7 +27,8 @@ export const dynamoDb = {
2727 javaOpts = '' ,
2828 } = options ?? { }
2929
30- if ( runningProcesses [ port ] ) return runningProcesses [ port ]
30+ if ( runningProcesses [ port ] )
31+ return runningProcesses [ port ]
3132
3233 const args = [
3334 '-Xrs' ,
@@ -53,18 +54,23 @@ export const dynamoDb = {
5354 const child = Bun . spawn ( [ 'java' , ...args ] , {
5455 cwd : config . installPath ,
5556 onExit : ( proc , exitCode , signalCode , error ) => {
56- if ( exitCode !== 0 && verbose ) debug ( 'Local DynamoDB exit code:' , exitCode )
57- if ( error ) debug ( 'Local DynamoDB error:' , error )
57+ if ( exitCode !== 0 && verbose )
58+ debug ( 'Local DynamoDB exit code:' , exitCode )
59+ if ( error )
60+ debug ( 'Local DynamoDB error:' , error )
5861 } ,
5962 } )
6063
61- if ( ! child . pid ) throw new Error ( 'Unable to launch DynamoDBLocal process' )
64+ if ( ! child . pid )
65+ throw new Error ( 'Unable to launch DynamoDBLocal process' )
6266
63- if ( ! detached ) process . on ( 'exit' , ( ) => child . kill ( ) )
67+ if ( ! detached )
68+ process . on ( 'exit' , ( ) => child . kill ( ) )
6469
6570 runningProcesses [ port ] = child
6671 return child
67- } catch ( error ) {
72+ }
73+ catch ( error ) {
6874 debug ( 'Error launching DynamoDB Local:' , error )
6975 throw error
7076 }
@@ -80,12 +86,15 @@ export const dynamoDb = {
8086
8187 async install ( ) : Promise < void > {
8288 const installPathExists = await exists ( config . installPath )
83- if ( ! installPathExists ) await promisify ( fs . mkdir ) ( config . installPath )
89+ if ( ! installPathExists )
90+ await promisify ( fs . mkdir ) ( config . installPath )
8491
8592 const jarPath = path . join ( config . installPath , JARNAME )
8693 const jarExists = await exists ( jarPath )
87- if ( jarExists ) return
94+ if ( jarExists )
95+ return
8896
97+ // eslint-disable-next-line no-console
8998 console . log ( 'Installing DynamoDB locally...' )
9099 const downloadUrl = config . downloadUrl
91100 await new Promise ( ( resolve , reject ) => {
0 commit comments