Skip to content

Commit

Permalink
validate extract
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJaredWilcurt committed Jan 1, 2024
1 parent e684512 commit bb419bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions nw-testing/manual-testing.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ function manualTesting () {
* @return {boolean} true = continue, false = retry/stop
*/
validateExtract: function (pathToExtract) {
console.log('validateExtract', pathToExtract);
const exists = fs.existsSync(pathToExtract);
console.log('Validate extract exists', pathToExtract, exists);
// This is just an example, you can put any logic you want here
return true;
return exists;
},
/**
* When download or extract fails, but we haven't
Expand Down
19 changes: 16 additions & 3 deletions src/downloadLatestAppAndOpenWindowInBackground/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,29 @@ async function downloadLatestAppAndOpenWindowInBackground (options) {
helpers.throwError(options, 'Issue found with your options.autoUpdate.validateZip function.', error);
}
}

if (!zipIsValid) {
return;
}

// extract zip
await extractZip(latestRemote);
const extractedSuccessfully = await extractZip(options, latestRemote);

console.log({ extractedSuccessfully });

// validate extraction
stub();
let extractIsValid = true;
if (options.autoUpdate.validateExtract) {
try {
const extractFilePath = helpers.getExtractPath(latestRemote);
extractIsValid = await options.autoUpdate.validateExtract(extractFilePath);
} catch (error) {
extractIsValid = false;
helpers.throwError(options, 'Issue found with your options.autoUpdate.validateExtract function.', error);
}
}
if (!extractIsValid) {
return;
}

// Update/Retry/Error/Complete
stub();
Expand Down

0 comments on commit bb419bf

Please sign in to comment.