@babel/helper-fixtures
Advanced tools
Comparing version 7.12.10 to 7.12.12
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.resolveOptionPluginOrPreset = resolveOptionPluginOrPreset; | ||
exports.default = get; | ||
@@ -230,2 +231,42 @@ exports.multiple = multiple; | ||
function wrapPackagesArray(type, names, optionsDir) { | ||
return names.map(function (val) { | ||
if (typeof val === "string") val = [val]; | ||
if (val[0][0] === ".") { | ||
if (!optionsDir) { | ||
throw new Error("Please provide an options.json in test dir when using a " + "relative plugin path."); | ||
} | ||
val[0] = _path.default.resolve(optionsDir, val[0]); | ||
} else { | ||
const monorepoPath = __dirname + "/../../babel-" + type + "-" + val[0]; | ||
if (_fs.default.existsSync(monorepoPath)) { | ||
val[0] = monorepoPath; | ||
} | ||
} | ||
return val; | ||
}); | ||
} | ||
function resolveOptionPluginOrPreset(options, optionsDir) { | ||
if (options.plugins) { | ||
options.plugins = wrapPackagesArray("plugin", options.plugins, optionsDir); | ||
} | ||
if (options.presets) { | ||
options.presets = wrapPackagesArray("preset", options.presets, optionsDir).map(function (val) { | ||
if (val.length > 3) { | ||
throw new Error("Unexpected extra options " + JSON.stringify(val.slice(3)) + " passed to preset."); | ||
} | ||
return val; | ||
}); | ||
} | ||
return options; | ||
} | ||
function get(entryLoc) { | ||
@@ -248,4 +289,7 @@ const suites = []; | ||
const suiteOptsLoc = tryResolve(suite.filename + "/options"); | ||
if (suiteOptsLoc) suite.options = require(suiteOptsLoc); | ||
if (suiteOptsLoc) { | ||
suite.options = resolveOptionPluginOrPreset(require(suiteOptsLoc), suite.filename); | ||
} | ||
for (const taskName of _fs.default.readdirSync(suite.filename)) { | ||
@@ -252,0 +296,0 @@ pushTask(taskName, suite.filename + "/" + taskName, suite, suiteName); |
{ | ||
"name": "@babel/helper-fixtures", | ||
"version": "7.12.10", | ||
"version": "7.12.12", | ||
"description": "Helper function to support fixtures", | ||
@@ -5,0 +5,0 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", |
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
10681
249