/
cli.js
83 lines (67 loc) · 2.8 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'use strict'
const common = require('../common')
const test = require('ava')
test('CLI argument test: --electron-version populates opts.electronVersion', t => {
let args = common.parseCLIArgs([])
t.is(args.electronVersion, undefined)
args = common.parseCLIArgs(['--electron-version=1.2.3'])
t.is(args.electronVersion, '1.2.3')
})
test('CLI argument test: --download.strictSSL default', t => {
const args = common.parseCLIArgs([])
t.true(args.download.strictSSL, 'default for --download.strictSSL is true')
})
test('CLI argument test: --asar=true', t => {
const args = common.parseCLIArgs(['--asar=true'])
t.true(args.asar)
})
test('CLI argument test: using --asar overrides other --asar.options', t => {
let args = common.parseCLIArgs(['--asar', '--asar.unpack=*.node'])
t.true(args.asar)
args = common.parseCLIArgs(['--asar.unpack=*.node', '--asar'])
t.true(args.asar)
})
test('CLI argument test: --osx-sign=true', t => {
const args = common.parseCLIArgs(['--osx-sign=true'])
t.true(args.osxSign)
})
test('CLI argument test: --osx-notarize=true', t => {
const args = common.parseCLIArgs(['--osx-notarize=true'])
t.falsy(args.osxNotarize, null)
})
test('CLI argument test: --osx-notarize is array', t => {
const args = common.parseCLIArgs(['--osx-notarize=1', '--osx-notarize=2'])
t.falsy(args.osxNotarize, null)
})
test('CLI argument test: --osx-notarize without --osx-sign', t => {
const args = common.parseCLIArgs(['--osx-notarize.appleId=myid'])
t.falsy(args.osxNotarize, null)
})
test('CLI argument test: --tmpdir=false', t => {
const args = common.parseCLIArgs(['--tmpdir=false'])
t.false(args.tmpdir)
})
test('CLI argument test: --deref-symlinks default', t => {
const args = common.parseCLIArgs([])
t.true(args.derefSymlinks)
})
test('CLI argument test: --out always resolves to a string', t => {
const args = common.parseCLIArgs(['--out=1'])
t.is(args.out, '1')
})
test('CLI argument test: --out without a value is the same as not passing --out', t => {
const args = common.parseCLIArgs(['--out'])
t.is(args.out, null)
})
test('CLI argument test: --protocol with a corresponding --protocol-name', t => {
const args = common.parseCLIArgs(['--protocol=foo', '--protocol-name=Foo'])
t.deepEqual(args.protocols, [{ schemes: ['foo'], name: 'Foo' }])
})
test('CLI argument test: --protocol without a corresponding --protocol-name', t => {
const args = common.parseCLIArgs(['--protocol=foo'])
t.deepEqual(args.protocols, undefined, 'no protocols have been fully defined')
})
test('CLI argument test: multiple --protocol/--protocol-name argument pairs', t => {
const args = common.parseCLIArgs(['--protocol=foo', '--protocol-name=Foo', '--protocol=bar', '--protocol-name=Bar'])
t.deepEqual(args.protocols, [{ schemes: ['foo'], name: 'Foo' }, { schemes: ['bar'], name: 'Bar' }])
})