forked from mapbox/dynamodb-replicator
-
Notifications
You must be signed in to change notification settings - Fork 6
/
package.ps1
31 lines (25 loc) · 1019 Bytes
/
package.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Write-Output "Packaging Lambda app"
if (Test-Path .\package) {
Remove-Item .\package -Recurse -Force
}
New-Item .\package -type directory -f | Out-Null
New-Item .\package\temp -type directory -f | Out-Null
Write-Output "Copying dependencies..."
Copy-Item .\backup.js .\package\temp\
Copy-Item .\diff.js .\package\temp\
Copy-Item .\s3-backfill.js .\package\temp\
Copy-Item .\s3-snapshot.js .\package\temp\
robocopy .\node_modules\ .\package\temp\ /E | Out-Null
Write-Output "Dependencies sorted"
Write-Output "Generating output..."
Copy-Item .\index.js .\package\temp\
Write-Output "Output generated"
Add-Type -assembly "system.io.compression.filesystem"
$currentPath = (Get-Item -Path ".\" -Verbose).FullName
$sourcePath = $currentPath + "\package\temp"
$outputFile = $currentPath + "\LambdaFunction.zip"
if (Test-Path $outputFile) {
Remove-Item $outputFile -Force
}
[io.compression.zipfile]::CreateFromDirectory($sourcePath, $outputFile)
Write-Output "λ function ready to be uploaded at: $($outputFile)"