@babel/helper-fixtures
Advanced tools
Comparing version 7.21.4-esm to 7.21.4-esm.1
@@ -1,18 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = get; | ||
exports.multiple = multiple; | ||
exports.readFile = readFile; | ||
exports.resolveOptionPluginOrPreset = resolveOptionPluginOrPreset; | ||
var _semver = require("semver"); | ||
var _path = require("path"); | ||
var _fs = require("fs"); | ||
var _url = require("url"); | ||
var _module = require("module"); | ||
const nodeVersion = _semver.clean(process.version.slice(1)); | ||
import semver from "semver"; | ||
import path from "path"; | ||
import fs from "fs"; | ||
import { fileURLToPath } from "url"; | ||
import { createRequire } from "module"; | ||
const require = createRequire(import.meta.url); | ||
const nodeVersion = semver.clean(process.version.slice(1)); | ||
function humanize(val, noext) { | ||
if (noext) val = _path.basename(val, _path.extname(val)); | ||
if (noext) val = path.basename(val, path.extname(val)); | ||
return val.replace(/-/g, " "); | ||
@@ -28,3 +20,3 @@ } | ||
function assertDirectory(loc) { | ||
if (!_fs.statSync(loc).isDirectory()) { | ||
if (!fs.statSync(loc).isDirectory()) { | ||
throw new Error(`Expected ${loc} to be a directory.`); | ||
@@ -37,4 +29,4 @@ } | ||
} | ||
const ext = _path.extname(name); | ||
const base = _path.basename(name, ext); | ||
const ext = path.extname(name); | ||
const base = path.basename(name, ext); | ||
return name[0] === "." || ext === ".md" || base === "LICENSE" || base === "options" || name === "package.json"; | ||
@@ -47,3 +39,3 @@ } | ||
const name = filepath + ext; | ||
if (_fs.existsSync(name)) matches.push(name); | ||
if (fs.existsSync(name)) matches.push(name); | ||
} | ||
@@ -57,7 +49,7 @@ if (matches.length > 1) { | ||
var _taskOpts$externalHel; | ||
const taskDirStats = _fs.statSync(taskDir); | ||
const taskDirStats = fs.statSync(taskDir); | ||
let actualLoc = findFile(taskDir + "/input"); | ||
let execLoc = findFile(taskDir + "/exec"); | ||
if (taskDirStats.isDirectory() && !actualLoc && !execLoc) { | ||
if (_fs.readdirSync(taskDir).length > 0) { | ||
if (fs.readdirSync(taskDir).length > 0) { | ||
console.warn(`Skipped test folder with invalid layout: ${taskDir}`); | ||
@@ -74,7 +66,7 @@ } | ||
const stderrLoc = taskDir + "/stderr.txt"; | ||
const actualLocAlias = suiteName + "/" + taskName + "/" + _path.basename(actualLoc); | ||
const expectLocAlias = suiteName + "/" + taskName + "/" + _path.basename(actualLoc); | ||
let execLocAlias = suiteName + "/" + taskName + "/" + _path.basename(actualLoc); | ||
const actualLocAlias = suiteName + "/" + taskName + "/" + path.basename(actualLoc); | ||
const expectLocAlias = suiteName + "/" + taskName + "/" + path.basename(actualLoc); | ||
let execLocAlias = suiteName + "/" + taskName + "/" + path.basename(actualLoc); | ||
if (taskDirStats.isFile()) { | ||
const ext = _path.extname(taskDir); | ||
const ext = path.extname(taskDir); | ||
if (EXTENSIONS.indexOf(ext) === -1) return; | ||
@@ -89,3 +81,3 @@ execLoc = taskDir; | ||
taskDir, | ||
optionsDir: taskOptsLoc ? _path.dirname(taskOptsLoc) : null, | ||
optionsDir: taskOptsLoc ? path.dirname(taskOptsLoc) : null, | ||
title: humanize(taskName, true), | ||
@@ -128,7 +120,7 @@ disabled: taskName[0] === "." || taskOpts.BABEL_8_BREAKING === true, | ||
if (taskOpts.minNodeVersion) { | ||
const minimumVersion = _semver.clean(taskOpts.minNodeVersion); | ||
const minimumVersion = semver.clean(taskOpts.minNodeVersion); | ||
if (minimumVersion == null) { | ||
throw new Error(`'minNodeVersion' has invalid semver format: ${taskOpts.minNodeVersion}`); | ||
} | ||
if (_semver.lt(nodeVersion, minimumVersion)) { | ||
if (semver.lt(nodeVersion, minimumVersion)) { | ||
return; | ||
@@ -156,3 +148,3 @@ } | ||
const sourceMapLoc = taskDir + "/source-map.json"; | ||
if (_fs.existsSync(sourceMapLoc)) { | ||
if (fs.existsSync(sourceMapLoc)) { | ||
test.sourceMap = JSON.parse(readFile(sourceMapLoc)); | ||
@@ -166,3 +158,3 @@ } | ||
const inputMapLoc = taskDir + "/input-source-map.json"; | ||
if (_fs.existsSync(inputMapLoc)) { | ||
if (fs.existsSync(inputMapLoc)) { | ||
test.inputSourceMap = JSON.parse(readFile(inputMapLoc)); | ||
@@ -200,3 +192,3 @@ } | ||
} | ||
val[0] = _path.resolve(optionsDir, val[0]); | ||
val[0] = path.resolve(optionsDir, val[0]); | ||
} else { | ||
@@ -208,4 +200,4 @@ let name = val[0]; | ||
} | ||
const monorepoPath = _path.join(_path.dirname(__filename), "../../..", name.startsWith("codemod") ? "codemods" : "packages", `babel-${type}-${name}/lib/index.js`); | ||
if (_fs.existsSync(monorepoPath)) { | ||
const monorepoPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "../../..", name.startsWith("codemod") ? "codemods" : "packages", `babel-${type}-${name}/lib/index.js`); | ||
if (fs.existsSync(monorepoPath)) { | ||
if (match) { | ||
@@ -220,3 +212,3 @@ throw new Error(`Remove the "${match[1]}" prefix from "${val[0]}", to load it from the monorepo`); | ||
} | ||
function resolveOptionPluginOrPreset(options, optionsDir) { | ||
export function resolveOptionPluginOrPreset(options, optionsDir) { | ||
if (options.plugins) { | ||
@@ -235,3 +227,3 @@ options.plugins = wrapPackagesArray("plugin", options.plugins, optionsDir); | ||
} | ||
function get(entryLoc) { | ||
export default function get(entryLoc) { | ||
const suites = []; | ||
@@ -241,3 +233,3 @@ let rootOpts = {}; | ||
if (rootOptsLoc) rootOpts = require(rootOptsLoc); | ||
for (const suiteName of _fs.readdirSync(entryLoc)) { | ||
for (const suiteName of fs.readdirSync(entryLoc)) { | ||
if (shouldIgnore(suiteName)) continue; | ||
@@ -256,3 +248,3 @@ const suite = { | ||
} | ||
for (const taskName of _fs.readdirSync(suite.filename)) { | ||
for (const taskName of fs.readdirSync(suite.filename)) { | ||
pushTask(taskName, suite.filename + "/" + taskName, suite, suiteName); | ||
@@ -263,7 +255,7 @@ } | ||
} | ||
function multiple(entryLoc, ignore) { | ||
export function multiple(entryLoc, ignore) { | ||
const categories = {}; | ||
for (const name of _fs.readdirSync(entryLoc)) { | ||
for (const name of fs.readdirSync(entryLoc)) { | ||
if (shouldIgnore(name, ignore)) continue; | ||
const loc = _path.join(entryLoc, name); | ||
const loc = path.join(entryLoc, name); | ||
assertDirectory(loc); | ||
@@ -274,5 +266,5 @@ categories[name] = get(loc); | ||
} | ||
function readFile(filename) { | ||
if (_fs.existsSync(filename)) { | ||
let file = _fs.readFileSync(filename, "utf8").trimRight(); | ||
export function readFile(filename) { | ||
if (fs.existsSync(filename)) { | ||
let file = fs.readFileSync(filename, "utf8").trimRight(); | ||
file = file.replace(/\r\n/g, "\n"); | ||
@@ -279,0 +271,0 @@ return file; |
{ | ||
"name": "@babel/helper-fixtures", | ||
"version": "7.21.4-esm", | ||
"version": "7.21.4-esm.1", | ||
"description": "Helper function to support fixtures", | ||
@@ -26,3 +26,3 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
}, | ||
"type": "commonjs" | ||
"type": "module" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
36001
312