Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix compatibility issue with ts-node/register #1463

Closed
wants to merge 1 commit into from
Closed
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
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