From 397e1fd1721083beaa4bd1959839d75b18551495 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Thu, 5 Jul 2018 02:09:26 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Allow=20for=20256kb=20piece=20le?= =?UTF-8?q?ngths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/failWithError.ts | 2 +- src/getManifest.ts | 4 ++-- src/getSolidpkg.ts | 8 ++++---- src/ssn/verify/verifySolidpkg.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/failWithError.ts b/src/failWithError.ts index 52cc177..6520bd0 100644 --- a/src/failWithError.ts +++ b/src/failWithError.ts @@ -1,6 +1,6 @@ export default function failWithError(usage: string, msg?: string) { if (msg !== undefined) { - process.stderr.write(`${msg.trim()}\n`); + process.stderr.write(`Error: ${msg.trim()}\n`); } process.stderr.write(`Usage: ${usage} \n`); process.exit(1); diff --git a/src/getManifest.ts b/src/getManifest.ts index bb8e447..7d46ca8 100644 --- a/src/getManifest.ts +++ b/src/getManifest.ts @@ -7,13 +7,13 @@ import verifyProductName from './ssn/verify/verifyProductName'; const failFunction = failWithError.bind(null, 'node dist/getManifest.js '); if (process.argv.length !== 3) { - failFunction(`Error: Expected 1 argument but ${process.argv.length - 2} arguments were supplied.`); + failFunction(`Expected 1 argument but ${process.argv.length - 2} arguments were supplied.`); } //Check that product name is valid const product = process.argv[2]; if (!verifyProductName(product)) { - failFunction(`Error: "${product} is not a valid product name.`); + failFunction(`"${product} is not a valid product name.`); } //Get manifest and write output to console diff --git a/src/getSolidpkg.ts b/src/getSolidpkg.ts index 7020f28..7d957dc 100644 --- a/src/getSolidpkg.ts +++ b/src/getSolidpkg.ts @@ -7,23 +7,23 @@ import verifyProductName from './ssn/verify/verifyProductName'; const failFunction = failWithError.bind(null, 'node dist/getSolidpkg.js '); if (process.argv.length !== 5) { - failFunction(`Error: Expected 3 arguments but ${process.argv.length - 2} arguments were supplied.`); + failFunction(`Expected 3 arguments but ${process.argv.length - 2} arguments were supplied.`); } //Check that product name is valid const product = process.argv[2]; if (!verifyProductName(product)) { - failFunction(`Error: "${product.substring(0, 300)}" is not a valid product name.`); + failFunction(`"${product.substring(0, 300)}" is not a valid product name.`); } //Check that from and to are valid numbers const from = process.argv[3]; const to = process.argv[4]; if (!from.match(/^(-1|0|[1-9][0-9]{0,2})$/)) { - failFunction(`Error: from value "${from.substring(0, 300)}" is not a valid integer; it must be in range [-1, 999].`); + failFunction(`from value "${from.substring(0, 300)}" is not a valid integer; it must be in range [-1, 999].`); } if (!to.match(/^(0|[1-9][0-9]{0,2})$/)) { - failFunction(`Error: to value "${to.substring(0, 300)}" is not a valid integer; it must be in range [0, 999].`); + failFunction(`to value "${to.substring(0, 300)}" is not a valid integer; it must be in range [0, 999].`); } //Get solidpkg and write output to console diff --git a/src/ssn/verify/verifySolidpkg.ts b/src/ssn/verify/verifySolidpkg.ts index 84e2b9e..04c618a 100644 --- a/src/ssn/verify/verifySolidpkg.ts +++ b/src/ssn/verify/verifySolidpkg.ts @@ -53,8 +53,8 @@ export default function verifySolidpkg(file: ISolid, { product, from, to }: {pro } } - if (!([0x1_0000, 0x8_0000, 0x40_0000]).includes(file.info['piece length'])) { - throw new Error(`Expected piece length to be "65536", "524288" or "4194304" but it was "${file.info['piece length']}".`); + if (!([0x1_0000, 0x4_0000, 0x8_0000, 0x40_0000]).includes(file.info['piece length'])) { + throw new Error(`Expected piece length to be "65536", "262144", 524288" or "4194304" but it was "${file.info['piece length']}".`); } if (typeof file.info.pieces !== 'string') { throw new Error(`Expected pieces to be a string but it was "${file.info.pieces}".`);