Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Module from "module"
import SemVer from "semver"
import assert from "assert"
import createNamespace from "./create-namespace.js"
import fs from "fs-extra"
import * as fsExtraNs from "fs-extra"
import * as fsNs from "fs"
import path from "path"
import require from "./require.js"
import resetState from "./reset-state.js"
import stream from "stream"
import trash from "../script/trash.js"
import util from "util"
const ESM_OPTIONS = JSON6.parse(process.env.ESM_OPTIONS || "{}")
const isDebug = !! ESM_OPTIONS.debug
const isWin = process.platform === "win32"
const canTestDuplexInstance = SemVer.satisfies(process.version, ">=6.8")
const canTestHasInstance = SemVer.satisfies(process.version, ">=6.5")
const canTestUtilFormatWithOptions = Reflect.has(util, "formatWithOptions")
const canTestUtilTypes = Reflect.has(util, "types")
const canTestWorker = SemVer.satisfies(process.version, ">=10.5")
const fileProtocol = "file://" + (isWin ? "/" : "")
const slashRegExp = /[\\/]/g
const indexPath = path.resolve("../index.js")
const pkgJSON = fs.readJSONSync("../package.json")
function tryParse(string) {
if (typeof string === "string" &&
string.length) {
try {
return parse(string)
} catch {}
}
return null
}