Repository: electron/electron-packager
Pull request #1047 (2019-08-31 02:02:43)

fix: send the properly formatted options from the CLI to electron-osx-sign
<!--
Thanks for filing a pull request!
Please check off all of the steps as they are completed by replacing [ ] with [x].
-->

* [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 testsuite passes successfully on my local machine (if applicable).

**Summarize your changes:**

Fix osx-sign can't get correctly sub properties, just use `osx-sign` arg instead of `osxSign`.

For `yargs-parser`, use camel case of args is meaning the subprops will be also converted to camel case, but it will break the [`osx-sign`](https://github.com/electron/electron-osx-sign/blob/master/sign.js#L307) usage like `entitlements-inherit`.

codecov-io: # [Codecov](https://codecov.io/gh/electron/electron-packager/pull/1047?src=pr&el=h1) Report
> Merging [#1047](https://codecov.io/gh/electron/electron-packager/pull/1047?src=pr&el=desc) into [master](https://codecov.io/gh/electron/electron-packager/commit/4ed0a4bf9c38b5db3c19c6f70cc285ba952004dc?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

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

```diff
@@          Coverage Diff           @@
##           master   #1047   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          14      14           
  Lines         689     691    +2     
======================================
+ Hits          689     691    +2
```


| [Impacted Files](https://codecov.io/gh/electron/electron-packager/pull/1047?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/cli.js](https://codecov.io/gh/electron/electron-packager/pull/1047/diff?src=pr&el=tree#diff-c3JjL2NsaS5qcw==) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/electron/electron-packager/pull/1047?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/1047?src=pr&el=footer). Last update [4ed0a4b...5d84a38](https://codecov.io/gh/electron/electron-packager/pull/1047?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/cli.js b/src/cli.js
index 57dae02..f158c72 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -67,6 +67,9 @@ module.exports = {
     if (args.osxSign === 'true') {
       warning('--osx-sign does not take any arguments, it only has sub-properties (see --help)')
       args.osxSign = true
+    } else if (typeof args.osxSign === 'object' && !Array.isArray(args.osxSign)) {
+      // Keep kebab case of sub properties
+      args.osxSign = args['osx-sign']
     }
 
     if (args.osxNotarize) {


Test patch:
diff --git a/test/cli.js b/test/cli.js
index e8eb280..891e030 100644
--- a/test/cli.js
+++ b/test/cli.js
@@ -37,6 +37,17 @@ test('CLI argument: --osx-sign=true', t => {
   t.true(args.osxSign)
 })
 
+test('CLI argument: --osx-sign is object', t => {
+  const args = cli.parseArgs([
+    '--osx-sign.identity=identity',
+    '--osx-sign.entitlements-inherit=path',
+    '--osx-sign.hardenedRuntime'
+  ])
+  t.is(args.osxSign.identity, 'identity')
+  t.is(args.osxSign['entitlements-inherit'], 'path')
+  t.true(args.osxSign.hardenedRuntime)
+})
+
 test('CLI argument: --osx-notarize=true', t => {
   const args = cli.parseArgs(['--osx-notarize=true'])
   t.falsy(args.osxNotarize, '')