cli.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. 'use strict'
  2. const common = require('../common')
  3. const test = require('ava')
  4. test('CLI argument test: --electron-version populates opts.electronVersion', t => {
  5. let args = common.parseCLIArgs([])
  6. t.is(args.electronVersion, undefined)
  7. args = common.parseCLIArgs(['--electron-version=1.2.3'])
  8. t.is(args.electronVersion, '1.2.3')
  9. })
  10. test('CLI argument test: --download.strictSSL default', t => {
  11. const args = common.parseCLIArgs([])
  12. t.true(args.download.strictSSL, 'default for --download.strictSSL is true')
  13. })
  14. test('CLI argument test: --asar=true', t => {
  15. const args = common.parseCLIArgs(['--asar=true'])
  16. t.true(args.asar)
  17. })
  18. test('CLI argument test: using --asar overrides other --asar.options', t => {
  19. let args = common.parseCLIArgs(['--asar', '--asar.unpack=*.node'])
  20. t.true(args.asar)
  21. args = common.parseCLIArgs(['--asar.unpack=*.node', '--asar'])
  22. t.true(args.asar)
  23. })
  24. test('CLI argument test: --osx-sign=true', t => {
  25. const args = common.parseCLIArgs(['--osx-sign=true'])
  26. t.true(args.osxSign)
  27. })
  28. test('CLI argument test: --tmpdir=false', t => {
  29. const args = common.parseCLIArgs(['--tmpdir=false'])
  30. t.false(args.tmpdir)
  31. })
  32. test('CLI argument test: --deref-symlinks default', t => {
  33. const args = common.parseCLIArgs([])
  34. t.true(args.derefSymlinks)
  35. })
  36. test('CLI argument test: --out always resolves to a string', t => {
  37. const args = common.parseCLIArgs(['--out=1'])
  38. t.is(args.out, '1')
  39. })
  40. test('CLI argument test: --out without a value is the same as not passing --out', t => {
  41. const args = common.parseCLIArgs(['--out'])
  42. t.is(args.out, null)
  43. })
  44. test('CLI argument test: --protocol with a corresponding --protocol-name', t => {
  45. const args = common.parseCLIArgs(['--protocol=foo', '--protocol-name=Foo'])
  46. t.deepEqual(args.protocols, [{schemes: ['foo'], name: 'Foo'}])
  47. })
  48. test('CLI argument test: --protocol without a corresponding --protocol-name', t => {
  49. const args = common.parseCLIArgs(['--protocol=foo'])
  50. t.deepEqual(args.protocols, undefined, 'no protocols have been fully defined')
  51. })
  52. test('CLI argument test: multiple --protocol/--protocol-name argument pairs', t => {
  53. const args = common.parseCLIArgs(['--protocol=foo', '--protocol-name=Foo', '--protocol=bar', '--protocol-name=Bar'])
  54. t.deepEqual(args.protocols, [{schemes: ['foo'], name: 'Foo'}, {schemes: ['bar'], name: 'Bar'}])
  55. })