Skip to content

Commit

Permalink
refactor(main): Refactor and improve internal code
Browse files Browse the repository at this point in the history
* Replaced use of deprecated function `substr` with `substring`
* Refined the logic of configuration file imports on `filterOptions` function
  • Loading branch information
mitsuki31 committed Jul 24, 2024
1 parent 7a15d76 commit 86853a2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const __version__ = (() => {
// eslint-disable-next-line prefer-const
let [ ver, rel ] = (pkg.version || '0.0.0-dev').split('-');
rel = (rel && rel.length !== 0)
? rel.charAt(0).toUpperCase() + rel.substr(1) // Capitalize first letter
? rel.charAt(0).toUpperCase() + rel.substring(1) // Capitalize first letter
: 'Stable';
return `\x1b[1m[${pkg.name.toUpperCase()}] v${ver} \x1b[2m${rel}\x1b[0m\n`;
})();
Expand Down Expand Up @@ -254,9 +254,13 @@ async function filterOptions({ options }) {
delete optionsCopy.quiet;

// Extract and resolve the download options from configuration file if given
const dlOptionsFromConfig = optionsCopy.config
? await /* may an ES module */ importConfig(optionsCopy.config)
let dlOptionsFromConfig = optionsCopy.config
? importConfig(optionsCopy.config)
: {};
// Await the download options if it is a promise
if (dlOptionsFromConfig instanceof Promise) {
dlOptionsFromConfig = await dlOptionsFromConfig;
}
const acOptionsFromConfig = dlOptionsFromConfig.converterOptions || {};
delete optionsCopy.config; // No longer needed
delete dlOptionsFromConfig.converterOptions; // No longer needed
Expand Down

0 comments on commit 86853a2

Please sign in to comment.