Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 12 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
"chalk": "^5.3.0",
"desm": "^1.3.1",
"execa": "^8.0.1",
"fs-extra": "^11.2.0",
"is-wsl": "^3.1.0",
"java-invoke-local": "0.0.6",
"jose": "^5.7.0",
Expand Down
10 changes: 5 additions & 5 deletions src/lambda/LambdaFunction.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import crypto from "node:crypto"
import { readFile, writeFile } from "node:fs/promises"
import { mkdir, readFile, rm, writeFile } from "node:fs/promises"
import { dirname, join, resolve } from "node:path"
import process from "node:process"
import { performance } from "node:perf_hooks"
import { setTimeout } from "node:timers/promises"
import { emptyDir, ensureDir, remove } from "fs-extra"
import jszip from "jszip"
import { log } from "../utils/log.js"
import renderIntrinsicFunction from "../utils/renderIntrinsicFunction.js"
Expand Down Expand Up @@ -226,7 +225,7 @@ export default class LambdaFunction {
// TODO console.log('lambda cleanup')
await this.#handlerRunner.cleanup()
if (this.#lambdaDir) {
await remove(this.#lambdaDir)
await rm(this.#lambdaDir, { force: true, recursive: true })
}
}

Expand All @@ -246,7 +245,8 @@ export default class LambdaFunction {
return
}

await emptyDir(this.#codeDir)
await rm(this.#codeDir, { force: true, recursive: true })
await mkdir(this.#codeDir, { recursive: true })

const data = await readFile(this.#artifact)
const zip = await jszip.loadAsync(data)
Expand All @@ -257,7 +257,7 @@ export default class LambdaFunction {
if (filename.endsWith("/")) {
return undefined
}
await ensureDir(join(this.#codeDir, dirname(filename)))
await mkdir(join(this.#codeDir, dirname(filename)), { recursive: true })
return writeFile(join(this.#codeDir, filename), fileData, {
mode: jsZipObj.unixPermissions,
})
Expand Down
13 changes: 6 additions & 7 deletions src/lambda/handler-runner/docker-runner/DockerContainer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { createHash } from "node:crypto"
import { createWriteStream } from "node:fs"
import { readFile, unlink, writeFile } from "node:fs/promises"
import { createWriteStream, existsSync } from "node:fs"
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises"
import { platform } from "node:os"
import { dirname, join, sep } from "node:path"
import { LambdaClient, GetLayerVersionCommand } from "@aws-sdk/client-lambda"
import { execa } from "execa"
import { ensureDir, pathExists } from "fs-extra"
import isWsl from "is-wsl"
import jszip from "jszip"
import { log, progress } from "../../../utils/log.js"
Expand Down Expand Up @@ -103,7 +102,7 @@ export default class DockerContainer {

layerDir = join(layerDir, this.#getLayersSha256())

if (await pathExists(layerDir)) {
if (existsSync(layerDir)) {
log.verbose(
`Layers already exist for this function. Skipping download.`,
)
Expand Down Expand Up @@ -143,7 +142,7 @@ export default class DockerContainer {
} else {
log.debug("Looking for bootstrap file")
const bootstrapDir = join(this.#servicePath, "bootstrap")
if (await pathExists(bootstrapDir)) {
if (existsSync(bootstrapDir)) {
log.debug(`Found bootstrap file at ${bootstrapDir}`)
dockerArgs.push(
"-v",
Expand Down Expand Up @@ -262,7 +261,7 @@ export default class DockerContainer {
const { CodeSize: layerSize, Location: layerUrl } = layer.Content
// const layerSha = layer.Content.CodeSha256

await ensureDir(layerDir)
await mkdir(layerDir, { recursive: true })

log.verbose(
`Retrieving "${layerName}": Downloading ${this.#formatBytes(
Expand Down Expand Up @@ -311,7 +310,7 @@ export default class DockerContainer {
if (filename.endsWith(sep)) {
return undefined
}
await ensureDir(join(layerDir, dirname(filename)))
await mkdir(join(layerDir, dirname(filename)), { recursive: true })
return writeFile(join(layerDir, filename), fileData, {
mode: zip.files[filename].unixPermissions,
})
Expand Down
5 changes: 2 additions & 3 deletions tests/_testHelpers/compressArtifact.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { createWriteStream } from "node:fs"
import { stat } from "node:fs/promises"
import { mkdir, stat } from "node:fs/promises"
import { dirname, resolve } from "node:path"
import archiver from "archiver"
import { ensureDir } from "fs-extra"

export default async function compressArtifact(baseDir, dest, src) {
const destPath = resolve(baseDir, dest)

await ensureDir(dirname(destPath))
await mkdir(dirname(destPath), { recursive: true })

return new Promise((res, rej) => {
const output = createWriteStream(destPath)
Expand Down