🔒 Verify input to releasePaths
This commit is contained in:
parent
620cb8bb1d
commit
053714bf10
1 changed files with 13 additions and 2 deletions
|
@ -1,5 +1,8 @@
|
||||||
|
import { Product } from '../interfaces/ISettings';
|
||||||
|
import verifyProductName from '../ssn/verifyProductName';
|
||||||
|
|
||||||
/** For the given release in the given product, returns from which releases we can patch to this release. */
|
/** For the given release in the given product, returns from which releases we can patch to this release. */
|
||||||
function getFroms({ product, to: releaseTo}: {product: string, to: number}) {
|
function getFroms({ product, to: releaseTo}: {product: Product, to: number}) {
|
||||||
//The launcher (patcher, patcher2014, patcher2017) is always installing from -1, never from a previous version
|
//The launcher (patcher, patcher2014, patcher2017) is always installing from -1, never from a previous version
|
||||||
if (product.startsWith('patcher')) {
|
if (product.startsWith('patcher')) {
|
||||||
return [-1];
|
return [-1];
|
||||||
|
@ -47,8 +50,16 @@ function getFroms({ product, to: releaseTo}: {product: string, to: number}) {
|
||||||
* Does not actually look at the manifest.xml file but theorizes on possible patches based on the usually created patches, allowing
|
* Does not actually look at the manifest.xml file but theorizes on possible patches based on the usually created patches, allowing
|
||||||
* us to find release pathes for products that have not been released yet.
|
* us to find release pathes for products that have not been released yet.
|
||||||
*/
|
*/
|
||||||
export default function findReleasePath({ product, from, to}: {product: string, from: number, to: number}): Array<[number, number]> {
|
export default function findReleasePath({ product, from, to}: {product: Product, from: number, to: number}): Array<[number, number]> {
|
||||||
|
//Verify function arguments
|
||||||
|
if (!verifyProductName(product)) {
|
||||||
|
throw new Error(`"${product}" is not a valid product.`);
|
||||||
|
}
|
||||||
|
|
||||||
//We assume that "from < to" is true for all patches
|
//We assume that "from < to" is true for all patches
|
||||||
|
if (from > to) {
|
||||||
|
throw new Error('Cannot patch backwards; to must be greater than from.');
|
||||||
|
}
|
||||||
|
|
||||||
const froms = getFroms({ product, to });
|
const froms = getFroms({ product, to });
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue