Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJaredWilcurt committed Dec 17, 2023
1 parent 3e2f6b6 commit bd856a4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
* Your own custom logging function called with helpful warning/error
* messages from the internal validators. Only used if verbose: true.
*
* @param {string} message The human readable warning/error message
* @param {object} error Sometimes an error or options object is passed
* @param {string} message The human readable warning/error message
* @param {object} error Sometimes an error or options object is passed
*/
customLogger: function (message, error) {
console.log(message, error);
Expand Down Expand Up @@ -59,9 +59,9 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
* download/extract. If no new version exists, then return false and the latest
* local version will be opened in a new window and the splash screen closed.
*
* @param {string} response The network respone from versionUrl
* @param {string} latestLocal The latest downloaded version, or undefined if not present
* @return {string} The new version number (continue to download zip), or false (open current version)
* @param {string} response The network respone from versionUrl
* @param {string} latestLocal The latest downloaded version, or undefined if not present
* @return {string} The new version number (continue to download zip), or false (open current version)
*/
confirmNewVersion: function (response, latestLocal) {
//This is just an example, you can put any logic you want here
Expand Down Expand Up @@ -91,9 +91,9 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
/**
* Called when an update occurs during download/extract.
*
* @param {object} update Object containing percents
* @param {number} update.downloadProgress The download progress percent
* @param {number} update.extractProgress The extract progress percent
* @param {object} update Object containing percents
* @param {number} update.downloadProgress The download progress percent
* @param {number} update.extractProgress The extract progress percent
*/
onUpdate: function ({ downloadProgress, extractProgress }) {
//This is just an example, you can put any logic you want here
Expand Down Expand Up @@ -146,11 +146,11 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
* all retries were exhausted.
*
* @param {string} errorMessage Human readable error message
* @param {object} err Detailed error information if available
* @param {object} error Detailed error information if available
*/
onError: function (errorMessage, err) {
onError: function (errorMessage, error) {
//This is just an example, you can put any logic you want here
console.log(errorMessage, err);
console.log(errorMessage, error);
},
/**
* Called just prior to opening the new window
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const nwSplasherAutoUpdate = {
downloadLatestAppAndOpenWindowInBackground: async function (options) {
options = validation.validateDownloadLatestAppAndOpenWindowInBackgroundOptions(options);
const data = await getVersionUrl(options);
console.log(typeof data);
console.log({ data });
// confirm version
// get download path
// download zip
Expand Down
3 changes: 2 additions & 1 deletion manual-testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
*/

const library = require('./index.js');
const semver = require('semver');

const options = {
autoUpdate: {
versionUrl: 'https://api.github.com/repos/scout-app/scout-app/releases',
confirmNewVersion: function (response, latestLocal) {
response = JSON.parse(response);
const latestRemote = response.latest.version;
const updateAvailable = require('semver').gt(latestRemote, latestLocal);
const updateAvailable = semver.gt(latestRemote, latestLocal);
if (updateAvailable) {
return latestRemote;
}
Expand Down
8 changes: 4 additions & 4 deletions src/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ const validation = {
* Loops over an array of strings of key names, deletes
* keys not found in the array from the object.
*
* @param {object} obj Any object with keys
* @param {string[]} keys Array of strings to be kept on the object
* @param {object} obj Any object with keys
* @param {string[]} keysToKeep Array of strings to be kept on the object
*/
deleteKeys: function (obj, keys) {
deleteKeys: function (obj, keysToKeep) {
for (const key of Object.keys(obj)) {
if (!keys.includes(key)) {
if (!keysToKeep.includes(key)) {
delete obj[key];
}
}
Expand Down

0 comments on commit bd856a4

Please sign in to comment.