Repository: jiahaog/nativefier
File: src/options/optionsMain.ts (TypeScript)

Code before:
      log.warn(
        `\nATTENTION: Using **old** Electron version ${requestedVersion} as requested.`,
        "\nIt's untested, bugs and horror will happen, you're on your own.",
        `\nSimply abort & re-run without passing the version flag to default to ${DEFAULT_ELECTRON_VERSION}`,
      );
    }
  }

  if (rawOptions.wvvmp) {
    process.env.ELECTRON_MIRROR =
      'https://github.com/castlabs/electron-releases/releases/download/';
    const electronVersion = options.packager.electronVersion;
    options.packager.electronVersion = `${electronVersion}-wvvmp`;
    try {
      await axios.get(
        `https://github.com/castlabs/electron-releases/releases/tag/v${electronVersion}-wvvmp`,
      );
    } catch (error) {
      throw `\nERROR: castLabs Electron version "${options.packager.electronVersion}" does not exist. \nVerify versions at https://github.com/castlabs/electron-releases/releases. \nAborting.`;
    }
    log.warn(
      `\nATTENTION: Using the **unofficial** Electron for Content Security from castLabs`,
      "\nIt implements Google's Widevine Content Decryption Module (CDM) for DRM-enabled playback.",
      `\nBe sure to select a valid version from https://github.com/castlabs/electron-releases/releases !`,
      `\nSimply abort & re-run without passing the wvvmp flag to default to ${DEFAULT_ELECTRON_VERSION}`,
    );
  }

  if (options.nativefier.flashPluginDir) {
    options.nativefier.insecure = true;
  }

  if (rawOptions.honest) {
    options.nativefier.userAgent = null;
  }

  const platform = options.packager.platform.toLowerCase();
  if (platform === 'windows') {
    options.packager.platform = 'win32';
  }

  if (['osx', 'mac', 'macos'].includes(platform)) {
    options.packager.platform = 'darwin';
  }

  if (options.nativefier.width > options.nativefier.maxWidth) {
    options.nativefier.width = options.nativefier.maxWidth;
  }

  if (options.nativefier.height > options.nativefier.maxHeight) {
    options.nativefier.height = options.nativefier.maxHeight;

Review comment (suggestion):
Nits:

1. Use an extra variable to clarify between electron version vs widevine-prefixed electron version
2. Use an empty line to separate the early exit from the actual work
3. `process.env.ELECTRON_MIRROR` should be set _after_ the early exit
4. No need to repeat `Be sure to select a valid version` in the log.warn, at this point we validated the requested version exists 🙂

```suggestion
    const widevineElectronVersion = `${options.packager.electronVersion}-wvvmp`;
    try {
      await axios.get(
        `https://github.com/castlabs/electron-releases/releases/tag/v${widevineElectronVersion}`,
      );
    } catch (error) {
      throw `\nERROR: castLabs Electron version "${widevineElectronVersion}" does not exist. \nVerify versions at https://github.com/castlabs/electron-releases/releases. \nAborting.`;
    }

    options.packager.electronVersion = widevineElectronVersion;
    process.env.ELECTRON_MIRROR =
      'https://github.com/castlabs/electron-releases/releases/download/';
    log.warn(
      `\nATTENTION: Using the **unofficial** Electron from castLabs`,
      "\nIt implements Google's Widevine Content Decryption Module (CDM) for DRM-enabled playback.",
      `\nSimply abort & re-run without passing the wvvmp flag to default to ${DEFAULT_ELECTRON_VERSION}`,
    );
```



Code after:
        `\nATTENTION: Using **old** Electron version ${requestedVersion} as requested.`,
        "\nIt's untested, bugs and horror will happen, you're on your own.",
        `\nSimply abort & re-run without passing the version flag to default to ${DEFAULT_ELECTRON_VERSION}`,
      );
    }
  }

  if (rawOptions.widevine) {
    const widevineElectronVersion = `${options.packager.electronVersion}-wvvmp`;
    try {
      await axios.get(
        `https://github.com/castlabs/electron-releases/releases/tag/v${widevineElectronVersion}`,
      );
    } catch (error) {
      throw `\nERROR: castLabs Electron version "${widevineElectronVersion}" does not exist. \nVerify versions at https://github.com/castlabs/electron-releases/releases. \nAborting.`;
    }

    options.packager.electronVersion = widevineElectronVersion;
    process.env.ELECTRON_MIRROR =
      'https://github.com/castlabs/electron-releases/releases/download/';
    log.warn(
      `\nATTENTION: Using the **unofficial** Electron from castLabs`,
      "\nIt implements Google's Widevine Content Decryption Module (CDM) for DRM-enabled playback.",
      `\nSimply abort & re-run without passing the widevine flag to default to ${DEFAULT_ELECTRON_VERSION}`,
    );
  }

  if (options.nativefier.flashPluginDir) {
    options.nativefier.insecure = true;
  }

  if (rawOptions.honest) {
    options.nativefier.userAgent = null;
  }

  const platform = options.packager.platform.toLowerCase();
  if (platform === 'windows') {
    options.packager.platform = 'win32';
  }

  if (['osx', 'mac', 'macos'].includes(platform)) {
    options.packager.platform = 'darwin';
  }

  if (options.nativefier.width > options.nativefier.maxWidth) {
    options.nativefier.width = options.nativefier.maxWidth;
  }

  if (options.nativefier.height > options.nativefier.maxHeight) {
    options.nativefier.height = options.nativefier.maxHeight;
  }