Repository: electron/electron-packager
Pull request #1083 (2019-11-22 19:53:43)

fix(win32): handle missing wine64 binaries in addition to wine
* [x] I have read the [contribution documentation](https://github.com/electron/electron-packager/blob/master/CONTRIBUTING.md) for this project.
* [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project follows, as appropriate.
* [x] The changes have sufficient test coverage (if applicable).
* [x] The testsuite passes successfully on my local machine (if applicable).

**Summarize your changes:**

node-rcedit 2.1.0 added support for wine64. Since Packager rewrites the error message to be more human-readable, it needs to take into account the new binary name possibility.

codecov-io: # [Codecov](https://codecov.io/gh/electron/electron-packager/pull/1083?src=pr&el=h1) Report
> Merging [#1083](https://codecov.io/gh/electron/electron-packager/pull/1083?src=pr&el=desc) into [master](https://codecov.io/gh/electron/electron-packager/commit/2e974d1211020eb22ac75c21cc0966b9bfaac216?src=pr&el=desc) will **decrease** coverage by `0.7%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/electron/electron-packager/pull/1083/graphs/tree.svg?width=650&token=sfG3Wa1sru&height=150&src=pr)](https://codecov.io/gh/electron/electron-packager/pull/1083?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1083      +/-   ##
==========================================
- Coverage   97.57%   96.87%   -0.71%     
==========================================
  Files          14       14              
  Lines         702      703       +1     
==========================================
- Hits          685      681       -4     
- Misses         17       22       +5
```


| [Impacted Files](https://codecov.io/gh/electron/electron-packager/pull/1083?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/win32.js](https://codecov.io/gh/electron/electron-packager/pull/1083/diff?src=pr&el=tree#diff-c3JjL3dpbjMyLmpz) | `100% <100%> (ø)` | :arrow_up: |
| [src/mac.js](https://codecov.io/gh/electron/electron-packager/pull/1083/diff?src=pr&el=tree#diff-c3JjL21hYy5qcw==) | `96.93% <0%> (-3.07%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/electron/electron-packager/pull/1083?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/electron/electron-packager/pull/1083?src=pr&el=footer). Last update [2e974d1...c170f18](https://codecov.io/gh/electron/electron-packager/pull/1083?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/win32.js b/src/win32.js
index b16b593..62ca2b6 100644
--- a/src/win32.js
+++ b/src/win32.js
@@ -7,11 +7,12 @@ const App = require('./platform')
 const common = require('./common')
 
 function updateWineMissingException (err) {
-  if (err && err.code === 'ENOENT' && err.syscall === 'spawn wine') {
-    err.message = 'Could not find "wine" on your system.\n\n' +
+  if (err && err.code === 'ENOENT' && ['spawn wine', 'spawn wine64'].includes(err.syscall)) {
+    const binary = err.syscall.split(' ')[1]
+    err.message = `Could not find "${binary}" on your system.\n\n` +
       'Wine is required to use the appCopyright, appVersion, buildVersion, icon, and \n' +
       'win32metadata parameters for Windows targets.\n\n' +
-      'Make sure that the "wine" executable is in your PATH.\n\n' +
+      `Make sure that the "${binary}" executable is in your PATH.\n\n` +
       'See https://github.com/electron/electron-packager#building-windows-apps-from-non-windows-platforms for details.'
   }
 


Test patch:
diff --git a/test/win32.js b/test/win32.js
index 1c3f9ba..9922ff2 100644
--- a/test/win32.js
+++ b/test/win32.js
@@ -134,17 +134,19 @@ function setCompanyNameTest (companyName) {
                                    'Company name should match win32metadata value')
 }
 
-test('better error message when wine is not found', (t) => {
-  let err = Error('spawn wine ENOENT')
-  err.code = 'ENOENT'
-  err.syscall = 'spawn wine'
-
-  t.is(err.message, 'spawn wine ENOENT')
-  err = win32.updateWineMissingException(err)
-  t.not(err.message, 'spawn wine ENOENT')
-})
+for (const wineBinary of ['wine', 'wine64']) {
+  test(`better error message when ${wineBinary} is not found`, t => {
+    let err = Error(`spawn ${wineBinary} ENOENT`)
+    err.code = 'ENOENT'
+    err.syscall = `spawn ${wineBinary}`
+
+    t.is(err.message, `spawn ${wineBinary} ENOENT`)
+    err = win32.updateWineMissingException(err)
+    t.not(err.message, `spawn ${wineBinary} ENOENT`)
+  })
+}
 
-test('error message unchanged when error not about wine', t => {
+test('error message unchanged when error not about wine/wine64', t => {
   let errNotEnoent = Error('unchanged')
   errNotEnoent.code = 'ESOMETHINGELSE'
   errNotEnoent.syscall = 'spawn wine'