Browse Source

Avoid failing when checking local binary

febo 1 year ago
parent
commit
d81e2d258d
1 changed files with 22 additions and 15 deletions
  1. 22 15
      template/base/scripts/program/dump.mjs

+ 22 - 15
template/base/scripts/program/dump.mjs

@@ -54,29 +54,36 @@ async function dump() {
       }
 
       if (hasShaChecksum) {
-        await copyFromChain(address, extension, 'onchain-');
-        const [onChainHash, localHash] = await Promise.all([
-          $`${sha} ${options} -b ${outputDir}/onchain-${binary} | cut -d ' ' -f 1`.quiet(),
-          $`${sha} ${options} -b ${outputDir}/${binary} | cut -d ' ' -f 1`.quiet(),
-        ]);
+        try {
+          await copyFromChain(address, extension, 'onchain-');
+          const [onChainHash, localHash] = await Promise.all([
+            $`${sha} ${options} -b ${outputDir}/onchain-${binary} | cut -d ' ' -f 1`.quiet(),
+            $`${sha} ${options} -b ${outputDir}/${binary} | cut -d ' ' -f 1`.quiet(),
+          ]);
 
-        if (onChainHash.toString() !== localHash.toString()) {
+          if (onChainHash.toString() !== localHash.toString()) {
+            echo(
+              chalk.yellow('[ WARNING ]'),
+              `on-chain and local binaries are different for '${address}'`
+            );
+          } else {
+            echo(
+              chalk.green('[ SKIPPED ]'),
+              `on-chain and local binaries are the same for '${address}'`
+            );
+          }
+
+          await $`rm ${outputDir}/onchain-${binary}`.quiet();
+        } catch (error) {
           echo(
             chalk.yellow('[ WARNING ]'),
-            `on-chain and local binaries are different for '${binary}'`
-          );
-        } else {
-          echo(
-            chalk.green('[ SKIPPED ]'),
-            `on-chain and local binaries are the same for '${binary}'`
+            `skipped check for '${address}' (error copying data from '${rpc}')`
           );
         }
-
-        await $`rm ${outputDir}/onchain-${binary}`.quiet();
       } else {
         echo(
           chalk.yellow('[ WARNING ]'),
-          `skipped check for '${binary}' (missing 'sha256sum' command)`
+          `skipped check for '${address}' (missing 'sha256sum' command)`
         );
       }
     })