forked from rockybars/atom-shell-packager
/
mas.js
58 lines (52 loc) · 2.1 KB
/
mas.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
'use strict'
const fs = require('fs-extra')
const packager = require('..')
const path = require('path')
const plist = require('plist')
const util = require('./_util')
if (!(process.env.CI && process.platform === 'win32')) {
const masOpts = {
name: 'masTest',
dir: util.fixtureSubdir('basic'),
electronVersion: '2.0.0-beta.1',
arch: 'x64',
platform: 'mas'
}
util.packagerTest('warn if building for mas and not signing', (t, baseOpts) => {
const warningLog = console.warn
let output = ''
console.warn = message => { output += message }
const finalize = err => {
console.warn = warningLog
if (err) throw err
}
return packager(Object.assign({}, baseOpts, masOpts))
.then(() =>
t.truthy(output.match(/signing is required for mas builds/), 'the correct warning is emitted')
).then(finalize)
.catch(finalize)
})
util.packagerTest('update Login Helper if it exists', (t, baseOpts) => {
let contentsPath
let plistPath
const helperName = `${masOpts.name} Login Helper`
return packager(Object.assign({}, baseOpts, masOpts))
.then(paths => {
contentsPath = path.join(paths[0], `${masOpts.name}.app`, 'Contents', 'Library', 'LoginItems', `${helperName}.app`, 'Contents')
return fs.pathExists(contentsPath)
}).then(exists => {
t.true(exists, 'renamed Login Helper app exists')
plistPath = path.join(contentsPath, 'Info.plist')
return fs.pathExists(contentsPath)
}).then(exists => {
t.true(exists, 'Login Helper Info.plist exists')
return fs.readFile(plistPath, 'utf8')
}).then(plistXML => {
const plistData = plist.parse(plistXML)
t.is(plistData.CFBundleExecutable, helperName, 'CFBundleExecutable is renamed Login Helper')
t.is(plistData.CFBundleName, helperName, 'CFBundleName is renamed Login Helper')
t.is(plistData.CFBundleIdentifier, 'com.electron.mastest.loginhelper')
return fs.pathExists(path.join(contentsPath, 'MacOS', helperName))
}).then(exists => t.true(exists, 'renamed Login Helper executable exists'))
})
}