Skip to content

Commit

Permalink
fix: Fix compatibility issue with ts-node/register
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasmayer committed Aug 6, 2024
1 parent 92d2525 commit c342a2c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions source/runner/runners/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import resultsForCaughtError from "./utils/resultsForCaughtError"

const d = debug("inline_runner")

const disableTranspilation = process.env.DANGER_DISABLE_TRANSPILATION === "true"

/**
* Executes a Dangerfile at a specific path, with a context.
* The values inside a Danger context are applied as globals to the Dangerfiles runtime.
Expand Down Expand Up @@ -73,13 +75,15 @@ export const runDangerfileEnvironment = async (
module._compile(compiled, filename)
}

const customRequire = moduleHandler || customModuleHandler
if (!disableTranspilation) {
const customRequire = moduleHandler || customModuleHandler

// Tell all these filetypes to get the custom compilation
require.extensions[".ts"] = customRequire
require.extensions[".tsx"] = customRequire
require.extensions[".js"] = customRequire
require.extensions[".jsx"] = customRequire
// Tell all these filetypes to get the custom compilation
require.extensions[".ts"] = customRequire
require.extensions[".tsx"] = customRequire
require.extensions[".js"] = customRequire
require.extensions[".jsx"] = customRequire
}

// Loop through all files and their potential contents, they edit
// results inside the env, so no need to keep track ourselves
Expand Down

0 comments on commit c342a2c

Please sign in to comment.