From bd856a4fd591b596455abaea19962a929ff5d4d2 Mon Sep 17 00:00:00 2001 From: The Jared Wilcurt Date: Sun, 17 Dec 2023 00:38:48 -0500 Subject: [PATCH] Minor cleanup --- README.md | 22 +++++++++++----------- index.js | 2 +- manual-testing.js | 3 ++- src/validation.js | 8 ++++---- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b6193b2..144d916 100644 --- a/README.md +++ b/README.md @@ -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); @@ -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 @@ -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 @@ -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 diff --git a/index.js b/index.js index 5adc5c6..bacda0d 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/manual-testing.js b/manual-testing.js index 5627319..d231ded 100644 --- a/manual-testing.js +++ b/manual-testing.js @@ -6,6 +6,7 @@ */ const library = require('./index.js'); +const semver = require('semver'); const options = { autoUpdate: { @@ -13,7 +14,7 @@ const options = { 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; } diff --git a/src/validation.js b/src/validation.js index 481296c..9122686 100644 --- a/src/validation.js +++ b/src/validation.js @@ -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]; } }