Skip to content

Commit

Permalink
search for bootstrap scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuss committed Jun 3, 2024
1 parent 63a6c4c commit 655c961
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/lambda/handler-runner/bootstrap-runner/BootstrapRunner.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import process from "node:process"
import { resolve } from "node:path"
import { execa } from "execa"
import { existsSync } from "node:fs"
import { log } from "../../../utils/log.js"
import RuntimeServer from "../../RuntimeServer.js"

const { parse } = JSON

const BOOTSTRAP_PATHS = [
"bootstrap",
"node_modules/.bin/bootstrap",
"/var/runtime/bootstrap",
]

export default class BootstrapRunner {
#codeDir = null

Expand Down Expand Up @@ -34,7 +41,21 @@ export default class BootstrapRunner {
this.#codeDir = codeDir
this.#timeout = timeout
this.#env = env
this.#bootstrap = resolve(codeDir, "./bootstrap")
this.#bootstrap = this.resolveBootstrap(codeDir)

if (!this.#bootstrap) {
throw new Error("Unable to locate boostrap a script", BOOTSTRAP_PATHS)
}
}

resolveBootstrap(codeDir) {
const path = BOOTSTRAP_PATHS.find((p) => existsSync(resolve(codeDir, p)))

if (!path) {
return undefined
}

return resolve(codeDir, path)
}

async cleanup() {
Expand Down

0 comments on commit 655c961

Please sign in to comment.