Detect if script is running in Runkit

30 Views Asked by At

How do I detect if the current environment which my script runs in is Runkit?

1

There are 1 best solutions below

0
Richie Bendall On BEST ANSWER

Runkit defines a lot of environmental variables that are sufficient to detect this. More specifically, we can detect RUNKIT_ENDPOINT_PATH, RUNKIT_ENDPOINT_URL, RUNKIT_MOUNT_PATH and RUNKIT_HOST:

const isRunkit = typeof process.env.RUNKIT_ENDPOINT_PATH === "string" &&
    typeof process.env.RUNKIT_ENDPOINT_URL === "string" &&
    typeof process.env.RUNKIT_MOUNT_PATH === "string" &&
    process.env.RUNKIT_HOST === "runkit.com"