Skip to content

Commit

Permalink
Async in the setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dakota002 committed Oct 4, 2023
1 parent 6fd1249 commit b036a60
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions setup-dynamodb-local.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import { existsSync, mkdirSync } from 'fs'
import { mkdir } from 'fs/promises'
import { existsSync } from 'fs'
import { execSync } from 'child_process'

const dynamodbDir = 'dynamodb_local_latest'
const dynamodbArchiveURL =
'https://s3.us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz'

// Check if the dynamodbDir directory exists
if (!existsSync(dynamodbDir)) {
// If it doesn't exist, create it
mkdirSync(dynamodbDir, { recursive: true })
async function runSetup() {
if (!existsSync(dynamodbDir)) {
// If it doesn't exist, create it
await mkdir(dynamodbDir, { recursive: true })

// Download and extract DynamoDB Local
try {
console.log('Downloading DynamoDB Local...')
execSync(`curl -L ${dynamodbArchiveURL} | tar -xz -C ${dynamodbDir}`, {
stdio: 'inherit',
})
console.log('DynamoDB Local setup completed successfully.')
} catch (error) {
console.error('Error setting up DynamoDB Local:', error.message)
process.exit(1)
// Download and extract DynamoDB Local
try {
console.log('Downloading DynamoDB Local...')
execSync(`curl -L ${dynamodbArchiveURL} | tar -xz -C ${dynamodbDir}`, {
stdio: 'inherit',
})
console.log('DynamoDB Local setup completed successfully.')
} catch (error) {
console.error('Error setting up DynamoDB Local:', error.message)
process.exit(1)
}
}
}

runSetup()

0 comments on commit b036a60

Please sign in to comment.