Merge pull request #3 from microsoft/jagore/check-update-symmetry
Make sure inherit check is symmetric with update behavior.
This commit is contained in:
Коммит
bdee81a662
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,8 +13,9 @@ export function generateInheritedPackageJson(cwd: string) {
|
||||||
for (const [pkg, info] of Object.entries(allPackages)) {
|
for (const [pkg, info] of Object.entries(allPackages)) {
|
||||||
// workspace-tools typings are not comprehensive about what is possible, so we force cast it
|
// workspace-tools typings are not comprehensive about what is possible, so we force cast it
|
||||||
if (info.inherits) {
|
if (info.inherits) {
|
||||||
const inheritInfo = (info.inherits as unknown) as InheritsInfo;
|
const inheritSpecifiers = (info.inherits as unknown) as InheritsInfo;
|
||||||
for (const specifier of inheritInfo) {
|
let mergedInheritInfo = {};
|
||||||
|
for (const specifier of inheritSpecifiers) {
|
||||||
const file = resolveInRepo(pkg, specifier, allPackages);
|
const file = resolveInRepo(pkg, specifier, allPackages);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
@ -23,11 +24,18 @@ export function generateInheritedPackageJson(cwd: string) {
|
||||||
|
|
||||||
const inheritInfo = JSON.parse(fs.readFileSync(file, "utf-8"));
|
const inheritInfo = JSON.parse(fs.readFileSync(file, "utf-8"));
|
||||||
|
|
||||||
|
// Merge inherit infos for given package together before checking shouldUpdate. This will
|
||||||
|
// allows inherit check behavior to be symmetric with update behavior, which updates packages
|
||||||
|
// defined in multiple inherit files to their last occurrence.
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (shouldUpdate(info[key], inheritInfo[key])) {
|
mergedInheritInfo[key] = { ...mergedInheritInfo[key], ...inheritInfo[key] };
|
||||||
info[key] = { ...(info[key] as any), ...inheritInfo[key] };
|
}
|
||||||
modifiedPackages.push(pkg);
|
}
|
||||||
}
|
|
||||||
|
for (const key of keys) {
|
||||||
|
if (shouldUpdate(info[key], mergedInheritInfo[key])) {
|
||||||
|
info[key] = { ...(info[key] as any), ...mergedInheritInfo[key] };
|
||||||
|
modifiedPackages.push(pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче