@yarnpkg/core
Advanced tools
Comparing version 2.0.0-rc.17 to 2.0.0-rc.18
@@ -324,3 +324,5 @@ "use strict"; | ||
if (!Array.isArray(value)) { | ||
return [parseSingleValue(configuration, path, value, definition, folder)]; | ||
return String(value).split(/,/).map(segment => { | ||
return parseSingleValue(configuration, path, segment, definition, folder); | ||
}); | ||
} else { | ||
@@ -528,2 +530,42 @@ return value.map((sub, i) => parseSingleValue(configuration, `${path}[${i}]`, sub, definition, folder)); | ||
const getDefault = object => { | ||
return object.default || object; | ||
}; | ||
const importPlugin = (pluginPath, source) => { | ||
const { | ||
factory, | ||
name | ||
} = nodeUtils.dynamicRequire(_fslib.npath.fromPortablePath(pluginPath)); // Prevent plugin redefinition so that the ones declared deeper in the | ||
// filesystem always have precedence over the ones below. | ||
if (dynamicPlugins.has(name)) return; | ||
const pluginRequireEntries = new Map(requireEntries); | ||
const pluginRequire = request => { | ||
if (pluginRequireEntries.has(request)) { | ||
return pluginRequireEntries.get(request)(); | ||
} else { | ||
throw new _clipanion.UsageError(`This plugin cannot access the package referenced via ${request} which is neither a builtin, nor an exposed entry`); | ||
} | ||
}; | ||
const plugin = miscUtils.prettifySyncErrors(() => { | ||
return getDefault(factory(pluginRequire)); | ||
}, message => { | ||
return `${message} (when initializing ${name}, defined in ${source})`; | ||
}); | ||
requireEntries.set(name, () => plugin); | ||
dynamicPlugins.add(name); | ||
plugins.set(name, plugin); | ||
}; | ||
if (environmentSettings.plugins) { | ||
for (const userProvidedPath of environmentSettings.plugins.split(`;`)) { | ||
const pluginPath = _fslib.ppath.resolve(startingCwd, _fslib.npath.toPortablePath(userProvidedPath)); | ||
importPlugin(pluginPath, `<environment>`); | ||
} | ||
} | ||
for (const { | ||
@@ -537,30 +579,8 @@ path, | ||
for (const userProvidedPath of data.plugins) { | ||
for (const userPluginEntry of data.plugins) { | ||
const userProvidedPath = typeof userPluginEntry !== `string` ? userPluginEntry.path : userPluginEntry; | ||
const pluginPath = _fslib.ppath.resolve(cwd, _fslib.npath.toPortablePath(userProvidedPath)); | ||
const { | ||
factory, | ||
name | ||
} = nodeUtils.dynamicRequire(_fslib.npath.fromPortablePath(pluginPath)); // Prevent plugin redefinition so that the ones declared deeper in the | ||
// filesystem always have precedence over the ones below. | ||
if (dynamicPlugins.has(name)) continue; | ||
const pluginRequireEntries = new Map(requireEntries); | ||
const pluginRequire = request => { | ||
if (pluginRequireEntries.has(request)) { | ||
return pluginRequireEntries.get(request)(); | ||
} else { | ||
throw new _clipanion.UsageError(`This plugin cannot access the package referenced via ${request} which is neither a builtin, nor an exposed entry`); | ||
} | ||
}; | ||
const plugin = miscUtils.prettifySyncErrors(() => { | ||
return factory(pluginRequire).default; | ||
}, message => { | ||
return `${message} (when initializing ${name}, defined in ${path})`; | ||
}); | ||
requireEntries.set(name, () => plugin); | ||
dynamicPlugins.add(name); | ||
plugins.set(name, plugin); | ||
importPlugin(pluginPath, path); | ||
} | ||
@@ -567,0 +587,0 @@ } |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.assertNever = assertNever; | ||
exports.mapAndFilter = mapAndFilter; | ||
exports.getArrayWithDefault = getArrayWithDefault; | ||
@@ -33,2 +34,19 @@ exports.getSetWithDefault = getSetWithDefault; | ||
function mapAndFilter(array, cb) { | ||
const output = []; | ||
for (const value of array) { | ||
const out = cb(value); | ||
if (out !== mapAndFilterSkip) { | ||
output.push(out); | ||
} | ||
} | ||
return output; | ||
} | ||
const mapAndFilterSkip = Symbol(); | ||
mapAndFilter.skip = mapAndFilterSkip; | ||
function getArrayWithDefault(map, key) { | ||
@@ -35,0 +53,0 @@ let value = map.get(key); |
{ | ||
"name": "@yarnpkg/core", | ||
"version": "2.0.0-rc.17", | ||
"version": "2.0.0-rc.18", | ||
"main": "./lib/index.js", | ||
@@ -9,4 +9,4 @@ "sideEffects": false, | ||
"@yarnpkg/json-proxy": "^2.0.0-rc.4", | ||
"@yarnpkg/parsers": "^2.0.0-rc.6", | ||
"@yarnpkg/pnp": "^2.0.0-rc.12", | ||
"@yarnpkg/parsers": "^2.0.0-rc.8", | ||
"@yarnpkg/pnp": "^2.0.0-rc.15", | ||
"@yarnpkg/shell": "^2.0.0-rc.4", | ||
@@ -44,5 +44,5 @@ "camelcase": "^5.3.1", | ||
"@types/tunnel": "^0.0.0", | ||
"@yarnpkg/cli": "^2.0.0-rc.19", | ||
"@yarnpkg/plugin-link": "^2.0.0-rc.7", | ||
"@yarnpkg/plugin-pnp": "^2.0.0-rc.11" | ||
"@yarnpkg/cli": "^2.0.0-rc.23", | ||
"@yarnpkg/plugin-link": "^2.0.0-rc.10", | ||
"@yarnpkg/plugin-pnp": "^2.0.0-rc.14" | ||
}, | ||
@@ -49,0 +49,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
262697
5981
Updated@yarnpkg/parsers@^2.0.0-rc.8
Updated@yarnpkg/pnp@^2.0.0-rc.15