зеркало из https://github.com/microsoft/beachball.git
Infinite loop fixed about the getting allowed change types during bump (#242)
* fixing a bug about infinite loop in allowed type * Change files * adding a launch.json update
This commit is contained in:
Родитель
65682a6e81
Коммит
3aa731e397
|
@ -29,6 +29,14 @@
|
|||
},
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach by Process ID",
|
||||
"processId": "${command:PickProcess}",
|
||||
"sourceMaps": true,
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type": "patch",
|
||||
"comment": "fixing a bug about infinite loop in allowed type",
|
||||
"packageName": "beachball",
|
||||
"email": "kchau@microsoft.com",
|
||||
"commit": "0344896618e0e5874288389c99e7d9530cc64c18",
|
||||
"dependentChangeType": "patch",
|
||||
"date": "2020-01-17T18:03:44.767Z"
|
||||
}
|
|
@ -5,4 +5,9 @@ describe('getAllowedChangeTypes', () => {
|
|||
const changeType = getAllowedChangeType('major', ['major', 'minor']);
|
||||
expect(changeType).toBe('patch');
|
||||
});
|
||||
|
||||
fit('can handle prerelease only case', () => {
|
||||
const changeType = getAllowedChangeType('patch', ['major', 'minor', 'patch']);
|
||||
expect(changeType).toBe('prerelease');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import { ChangeInfo, ChangeSet, ChangeType } from '../types/ChangeInfo';
|
||||
|
||||
const ChangeTypeWeights = {
|
||||
major: 4,
|
||||
minor: 3,
|
||||
patch: 2,
|
||||
prerelease: 1,
|
||||
none: 0,
|
||||
};
|
||||
const SortedChangeTypes: ChangeType[] = ['none', 'prerelease', 'patch', 'minor', 'major'];
|
||||
|
||||
/**
|
||||
* Change type weights
|
||||
* Note: the order in which this is defined is IMPORTANT
|
||||
*/
|
||||
const ChangeTypeWeights = SortedChangeTypes.reduce((weights, changeType, index) => {
|
||||
weights[changeType] = index;
|
||||
return weights;
|
||||
}, {});
|
||||
|
||||
export function getPackageChangeTypes(changeSet: ChangeSet) {
|
||||
const changePerPackage: {
|
||||
|
@ -40,8 +43,8 @@ export function getAllowedChangeType(changeType: ChangeType, disallowedChangeTyp
|
|||
}
|
||||
|
||||
while (disallowedChangeTypes.includes(changeType) && changeType !== 'none') {
|
||||
// minus 2 here because of 0 and 1 based index conversion
|
||||
changeType = Object.keys(ChangeTypeWeights)[ChangeTypeWeights[changeType] - 2] as keyof typeof ChangeTypeWeights;
|
||||
const nextChangeTypeWeight = ChangeTypeWeights[changeType] - 1;
|
||||
changeType = SortedChangeTypes[nextChangeTypeWeight];
|
||||
}
|
||||
|
||||
return changeType;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"moduleResolution": "node",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"esModuleInterop": true,
|
||||
|
|
Загрузка…
Ссылка в новой задаче