Clean up logPlugin
This commit is contained in:
parent
3cea9f412a
commit
080c7f1e2d
@ -12,27 +12,30 @@ export const logMessage = (message, context) => {
|
|||||||
console.log(logStr);
|
console.log(logStr);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const logPlugin = (plugin, targets, list, context) => {
|
// Outputs a message that shows which target(s) caused an item to be included:
|
||||||
const envList = list[plugin] || {};
|
// transform-foo { "edge":"13", "firefox":"49", "ie":"10" }
|
||||||
const filteredList = Object.keys(targets).reduce((a, b) => {
|
export const logPlugin = (item, targetVersions, list, context) => {
|
||||||
const version = envList[b];
|
const minVersions = list[item] || {};
|
||||||
const target = targets[b];
|
|
||||||
|
|
||||||
if (!version) {
|
const filteredList = Object.keys(targetVersions).reduce((result, env) => {
|
||||||
a[b] = prettifyVersion(target);
|
const minVersion = minVersions[env];
|
||||||
|
const targetVersion = targetVersions[env];
|
||||||
|
|
||||||
|
if (!minVersion) {
|
||||||
|
result[env] = prettifyVersion(targetVersion);
|
||||||
} else {
|
} else {
|
||||||
const versionIsUnreleased = isUnreleasedVersion(version, b);
|
const minIsUnreleased = isUnreleasedVersion(minVersion, env);
|
||||||
const targetIsUnreleased = isUnreleasedVersion(target, b);
|
const targetIsUnreleased = isUnreleasedVersion(targetVersion, env);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(versionIsUnreleased && !targetIsUnreleased) ||
|
!targetIsUnreleased &&
|
||||||
(!targetIsUnreleased && semver.lt(target, semverify(version)))
|
(minIsUnreleased || semver.lt(targetVersion, semverify(minVersion)))
|
||||||
) {
|
) {
|
||||||
a[b] = prettifyVersion(target);
|
result[env] = prettifyVersion(targetVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
return result;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const formattedTargets = JSON.stringify(filteredList)
|
const formattedTargets = JSON.stringify(filteredList)
|
||||||
@ -40,7 +43,7 @@ export const logPlugin = (plugin, targets, list, context) => {
|
|||||||
.replace(/^\{"/, '{ "')
|
.replace(/^\{"/, '{ "')
|
||||||
.replace(/"\}$/, '" }');
|
.replace(/"\}$/, '" }');
|
||||||
|
|
||||||
logMessage(`${plugin} ${formattedTargets}`, context);
|
logMessage(`${item} ${formattedTargets}`, context);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const logEntryPolyfills = (
|
export const logEntryPolyfills = (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user