1
0
mirror of https://github.com/S2-/gitlit synced 2025-08-03 21:00:04 +02:00

update dependencies

This commit is contained in:
s2
2018-10-09 09:51:34 +02:00
parent 4fcc873901
commit da4083f574
1112 changed files with 23205 additions and 21697 deletions

View File

@@ -7,6 +7,7 @@ const config = require('./config.json')
const fs = require('fs-extra')
const packager = require('../index')
const path = require('path')
const plist = require('plist')
const setup = require('./_setup')
const tempy = require('tempy')
const test = require('ava')
@@ -45,17 +46,32 @@ function testSinglePlatform (name, testFunction, testFunctionArgs, parallel) {
module.exports = {
allPlatformArchCombosCount: 9,
areFilesEqual: function areFilesEqual (file1, file2) {
let buffer1, buffer2
return fs.readFile(file1)
.then((data) => {
buffer1 = data
return fs.readFile(file2)
}).then((data) => {
buffer2 = data
return bufferEqual(buffer1, buffer2)
})
assertDirectory: function assertDirectory (t, pathToCheck, message) {
return fs.stat(pathToCheck)
.then(stats => t.true(stats.isDirectory(), message))
},
assertFile: function assertFile (t, pathToCheck, message) {
return fs.stat(pathToCheck)
.then(stats => t.true(stats.isFile(), message))
},
assertFilesEqual: function assertFilesEqual (t, file1, file2, message) {
return Promise.all([fs.readFile(file1), fs.readFile(file2)])
.then(([buffer1, buffer2]) => bufferEqual(buffer1, buffer2))
.then(equal => t.true(equal, message))
},
assertPathExistsCustom: function assertPathExistsCustom (t, pathToCheck, exists, message) {
return fs.pathExists(pathToCheck)
.then(result => t.is(exists, result, message))
},
assertPathExists: function assertPathExists (t, pathToCheck, message) {
return module.exports.assertPathExistsCustom(t, pathToCheck, true, message)
},
assertPathNotExists: function assertPathNotExists (t, pathToCheck, message) {
return module.exports.assertPathExistsCustom(t, pathToCheck, false, message)
},
assertSymlink: function assertFile (t, pathToCheck, message) {
return fs.lstat(pathToCheck)
.then(stats => t.true(stats.isSymbolicLink(), message))
},
fixtureSubdir: setup.fixtureSubdir,
generateResourcesPath: function generateResourcesPath (opts) {
@@ -72,11 +88,8 @@ module.exports = {
return packager(opts)
.then(paths => {
resourcesPath = path.join(paths[0], module.exports.generateResourcesPath(opts))
return fs.stat(resourcesPath)
}).then(stats => {
t.true(stats.isDirectory(), 'The output directory should contain the expected resources subdirectory')
return resourcesPath
})
return module.exports.assertDirectory(t, resourcesPath, 'The output directory should contain the expected resources subdirectory')
}).then(() => resourcesPath)
},
packagerTest: function packagerTest (name, testFunction, parallel) {
const testDefinition = parallel ? test : test.serial
@@ -88,6 +101,13 @@ module.exports = {
})
})
},
parsePlist: function parsePlist (t, appPath) {
const plistPath = path.join(appPath, 'Contents', 'Info.plist')
return module.exports.assertFile(t, plistPath, `The expected Info.plist should exist in ${path.basename(appPath)}`)
.then(() => fs.readFile(plistPath, 'utf8'))
.then(file => plist.parse(file))
},
singlePlatformOptions: function singlePlatformOptions () {
return {
platform: 'linux',
@@ -106,7 +126,7 @@ module.exports = {
return testSinglePlatform(name, testFunction, testFunctionArgs, true)
},
verifyPackageExistence: function verifyPackageExistence (finalPaths) {
return Promise.all(finalPaths.map((finalPath) => {
return Promise.all(finalPaths.map(finalPath => {
return fs.stat(finalPath)
.then(
stats => stats.isDirectory(),

View File

@@ -1,7 +1,6 @@
'use strict'
const common = require('../common')
const fs = require('fs-extra')
const path = require('path')
const test = require('ava')
const util = require('./_util')
@@ -25,10 +24,14 @@ util.testSinglePlatform('default_app.asar removal test', (t, opts) => {
opts.electronVersion = '0.37.4'
return util.packageAndEnsureResourcesPath(t, opts)
.then(resourcesPath => fs.pathExists(path.join(resourcesPath, 'default_app.asar')))
.then(exists => t.false(exists, 'The output directory should not contain the Electron default_app.asar file'))
.then(resourcesPath => util.assertPathNotExists(t, path.join(resourcesPath, 'default_app.asar'), 'The output directory should not contain the Electron default_app.asar file'))
})
function assertUnpackedAsar (t, resourcesPath) {
return util.assertDirectory(t, path.join(resourcesPath, 'app.asar.unpacked'), 'app.asar.unpacked should exist under the resources subdirectory when opts.asar_unpack is set')
.then(() => util.assertDirectory(t, path.join(resourcesPath, 'app.asar.unpacked', 'dir_to_unpack'), 'dir_to_unpack should exist under app.asar.unpacked subdirectory when opts.asar-unpack-dir is set dir_to_unpack'))
}
util.testSinglePlatform('asar test', (t, opts) => {
opts.name = 'asarTest'
opts.dir = util.fixtureSubdir('basic')
@@ -36,20 +39,13 @@ util.testSinglePlatform('asar test', (t, opts) => {
'unpack': '*.pac',
'unpackDir': 'dir_to_unpack'
}
let resourcesPath
return util.packageAndEnsureResourcesPath(t, opts)
.then(generatedResourcesPath => {
resourcesPath = generatedResourcesPath
return fs.stat(path.join(resourcesPath, 'app.asar'))
}).then(stats => {
t.true(stats.isFile(), 'app.asar should exist under the resources subdirectory when opts.asar is true')
return fs.pathExists(path.join(resourcesPath, 'app'))
}).then(exists => {
t.false(exists, 'app subdirectory should NOT exist when app.asar is built')
return fs.stat(path.join(resourcesPath, 'app.asar.unpacked'))
}).then(stats => {
t.true(stats.isDirectory(), 'app.asar.unpacked should exist under the resources subdirectory when opts.asar_unpack is set some expression')
return fs.stat(path.join(resourcesPath, 'app.asar.unpacked', 'dir_to_unpack'))
}).then(stats => t.true(stats.isDirectory(), 'dir_to_unpack should exist under app.asar.unpacked subdirectory when opts.asar-unpack-dir is set dir_to_unpack'))
.then(resourcesPath => {
return Promise.all([
util.assertFile(t, path.join(resourcesPath, 'app.asar'), 'app.asar should exist under the resources subdirectory when opts.asar is true'),
util.assertPathNotExists(t, path.join(resourcesPath, 'app'), 'app subdirectory should NOT exist when app.asar is built'),
assertUnpackedAsar(t, resourcesPath)
])
})
})

View File

@@ -3,7 +3,7 @@
const common = require('../common')
const download = require('../download')
const fs = require('fs-extra')
const hostArch = require('../targets').hostArch
const hostArch = require('electron-download/lib/arch').host
const packager = require('..')
const path = require('path')
const test = require('ava')
@@ -118,35 +118,22 @@ util.testSinglePlatform('defaults test', (t, opts) => {
finalPath = paths[0]
t.is(finalPath, path.join(t.context.workDir, common.generateFinalBasename(defaultOpts)),
'Path should follow the expected format and be in the cwd')
return fs.stat(finalPath)
}).then(stats => {
t.true(stats.isDirectory(), 'The expected output directory should exist')
return util.assertDirectory(t, finalPath, 'The expected output directory should exist')
}).then(() => {
resourcesPath = path.join(finalPath, util.generateResourcesPath(defaultOpts))
return fs.stat(path.join(finalPath, generateNamePath(defaultOpts)))
}).then(stats => {
const appPath = path.join(finalPath, generateNamePath(defaultOpts))
if (common.isPlatformMac(defaultOpts.platform)) {
t.true(stats.isDirectory(), 'The Helper.app should reflect opts.name')
return util.assertDirectory(t, appPath, 'The Helper.app should reflect opts.name')
} else {
t.true(stats.isFile(), 'The executable should reflect opts.name')
return util.assertFile(t, appPath, 'The executable should reflect opts.name')
}
return fs.stat(resourcesPath)
}).then(stats => {
t.true(stats.isDirectory(), 'The output directory should contain the expected resources subdirectory')
return fs.pathExists(path.join(resourcesPath, 'app', 'node_modules', 'run-waterfall'))
}).then(exists => {
t.false(exists, 'The output directory should NOT contain devDependencies by default (prune=true)')
return util.areFilesEqual(path.join(opts.dir, 'main.js'), path.join(resourcesPath, 'app', 'main.js'))
}).then(equal => {
t.true(equal, 'File under packaged app directory should match source file')
return util.areFilesEqual(path.join(opts.dir, 'ignore', 'this.txt'),
path.join(resourcesPath, 'app', 'ignore', 'this.txt'))
}).then(equal => {
t.true(equal, 'File under subdirectory of packaged app directory should match source file and not be ignored by default')
return fs.pathExists(path.join(resourcesPath, 'default_app'))
}).then(exists => {
t.false(exists, 'The output directory should not contain the Electron default_app directory')
return fs.pathExists(path.join(resourcesPath, 'default_app.asar'))
}).then(exists => t.false(exists, 'The output directory should not contain the Electron default_app.asar file'))
}).then(() => util.assertDirectory(t, resourcesPath, 'The output directory should contain the expected resources subdirectory'))
.then(() => util.assertPathNotExists(t, path.join(resourcesPath, 'app', 'node_modules', 'run-waterfall'), 'The output directory should NOT contain devDependencies by default (prune=true)'))
.then(() => util.assertFilesEqual(t, path.join(opts.dir, 'main.js'), path.join(resourcesPath, 'app', 'main.js'), 'File under packaged app directory should match source file'))
.then(() => util.assertFilesEqual(t, path.join(opts.dir, 'ignore', 'this.txt'), path.join(resourcesPath, 'app', 'ignore', 'this.txt'), 'File under subdirectory of packaged app directory should match source file and not be ignored by default'))
.then(() => util.assertPathNotExists(t, path.join(resourcesPath, 'default_app'), 'The output directory should not contain the Electron default_app directory'))
.then(() => util.assertPathNotExists(t, path.join(resourcesPath, 'default_app.asar'), 'The output directory should not contain the Electron default_app.asar file'))
})
util.testSinglePlatform('out test', (t, opts) => {
@@ -161,11 +148,8 @@ util.testSinglePlatform('out test', (t, opts) => {
finalPath = paths[0]
t.is(finalPath, path.join('dist', common.generateFinalBasename(opts)),
'Path should follow the expected format and be under the folder specified in `out`')
return fs.stat(finalPath)
}).then(stats => {
t.true(stats.isDirectory(), 'The expected output directory should exist')
return fs.stat(path.join(finalPath, util.generateResourcesPath(opts)))
}).then(stats => t.true(stats.isDirectory(), 'The output directory should contain the expected resources subdirectory'))
return util.assertDirectory(t, finalPath, 'The expected output directory should exist')
}).then(() => util.assertDirectory(t, path.join(finalPath, util.generateResourcesPath(opts)), 'The output directory should contain the expected resources subdirectory'))
})
util.testSinglePlatform('overwrite test', (t, opts) => {
@@ -178,21 +162,18 @@ util.testSinglePlatform('overwrite test', (t, opts) => {
return packager(opts)
.then(paths => {
finalPath = paths[0]
return fs.stat(finalPath)
}).then(stats => {
t.true(stats.isDirectory(), 'The expected output directory should exist')
return util.assertDirectory(t, finalPath, 'The expected output directory should exist')
}).then(() => {
// Create a dummy file to detect whether the output directory is replaced in subsequent runs
testPath = path.join(finalPath, 'test.txt')
return fs.writeFile(testPath, 'test')
}).then(() => packager(opts)) // Run again, defaulting to overwrite false
.then(paths => fs.stat(testPath))
.then(stats => {
t.true(stats.isFile(), 'The existing output directory should exist as before (skipped by default)')
.then(paths => util.assertFile(t, testPath, 'The existing output directory should exist as before (skipped by default)'))
.then(() => {
// Run a third time, explicitly setting overwrite to true
opts.overwrite = true
return packager(opts)
}).then(paths => fs.pathExists(testPath))
.then(exists => t.false(exists, 'The output directory should be regenerated when overwrite is true'))
}).then(paths => util.assertPathNotExists(t, testPath, 'The output directory should be regenerated when overwrite is true'))
})
util.testSinglePlatform('overwrite test sans platform/arch set', (t, opts) => {
@@ -202,12 +183,9 @@ util.testSinglePlatform('overwrite test sans platform/arch set', (t, opts) => {
opts.overwrite = true
return packager(opts)
.then(paths => fs.pathExists(paths[0]))
.then(exists => {
t.true(exists, 'The output directory exists')
return packager(opts)
}).then(paths => fs.pathExists(paths[0]))
.then(exists => t.true(exists, 'The output directory exists'))
.then(paths => util.assertPathExists(t, paths[0], 'The output directory exists'))
.then(() => packager(opts))
.then(paths => util.assertPathExists(t, paths[0], 'The output directory exists'))
})
util.testSinglePlatform('tmpdir test', (t, opts) => {
@@ -217,8 +195,7 @@ util.testSinglePlatform('tmpdir test', (t, opts) => {
opts.tmpdir = path.join(t.context.workDir, 'tmp')
return packager(opts)
.then(paths => fs.stat(path.join(opts.tmpdir, 'electron-packager')))
.then(stats => t.true(stats.isDirectory(), 'The expected temp directory should exist'))
.then(paths => util.assertDirectory(t, path.join(opts.tmpdir, 'electron-packager'), 'The expected temp directory should exist'))
})
util.testSinglePlatform('disable tmpdir test', (t, opts) => {
@@ -228,8 +205,7 @@ util.testSinglePlatform('disable tmpdir test', (t, opts) => {
opts.tmpdir = false
return packager(opts)
.then(paths => fs.stat(paths[0]))
.then(stats => t.true(stats.isDirectory(), 'The expected out directory should exist'))
.then(paths => util.assertDirectory(t, paths[0], 'The expected out directory should exist'))
})
util.testSinglePlatform('deref symlink test', (t, opts) => {
@@ -244,11 +220,8 @@ util.testSinglePlatform('deref symlink test', (t, opts) => {
.then(() => packager(opts))
.then(paths => {
const destLink = path.join(paths[0], 'resources', 'app', 'main-link.js')
return fs.lstat(destLink)
}).then(stats => {
t.true(stats.isSymbolicLink(), 'The expected file should still be a symlink')
return fs.remove(dest)
})
return util.assertSymlink(t, destLink, 'The expected file should still be a symlink')
}).then(() => fs.remove(dest))
})
function createExtraResourceStringTest (t, opts, platform) {
@@ -262,8 +235,7 @@ function createExtraResourceStringTest (t, opts, platform) {
opts.extraResource = extra1Path
return util.packageAndEnsureResourcesPath(t, opts)
.then(resourcesPath => util.areFilesEqual(extra1Path, path.join(resourcesPath, extra1Base)))
.then(equal => t.true(equal, 'resource file data1.txt should match'))
.then(resourcesPath => util.assertFilesEqual(t, extra1Path, path.join(resourcesPath, extra1Base), 'resource file data1.txt should match'))
}
function createExtraResourceArrayTest (t, opts, platform) {
@@ -285,17 +257,10 @@ function createExtraResourceArrayTest (t, opts, platform) {
.then(resourcesPath => {
extra1DistPath = path.join(resourcesPath, extra1Base)
extra2DistPath = path.join(resourcesPath, extra2Base)
return fs.pathExists(extra1DistPath)
}).then(exists => {
t.true(exists, 'resource file data1.txt exists')
return util.areFilesEqual(extra1Path, extra1DistPath)
}).then(equal => {
t.true(equal, 'resource file data1.txt should match')
return fs.pathExists(extra2DistPath)
}).then(exists => {
t.true(exists, 'resource file extrainfo.plist exists')
return util.areFilesEqual(extra2Path, extra2DistPath)
}).then(equal => t.true(equal, 'resource file extrainfo.plist should match'))
return util.assertPathExists(t, extra1DistPath, 'resource file data1.txt exists')
}).then(() => util.assertFilesEqual(t, extra1Path, extra1DistPath, 'resource file data1.txt should match'))
.then(() => util.assertPathExists(t, extra2DistPath, 'resource file extrainfo.plist exists'))
.then(() => util.assertFilesEqual(t, extra2Path, extra2DistPath, 'resource file extrainfo.plist should match'))
}
for (const platform of ['darwin', 'linux']) {
@@ -310,8 +275,8 @@ util.testSinglePlatform('building for Linux target sanitizes binary name', (t, o
return packager(opts)
.then(paths => {
t.is(1, paths.length, '1 bundle created')
return fs.stat(path.join(paths[0], '@username-package-name'))
}).then(stats => t.true(stats.isFile(), 'The sanitized binary filename should exist'))
return util.assertFile(t, path.join(paths[0], '@username-package-name'), 'The sanitized binary filename should exist')
})
})
util.testSinglePlatform('executableName honored when building for Linux target', (t, opts) => {
@@ -322,8 +287,8 @@ util.testSinglePlatform('executableName honored when building for Linux target',
return packager(opts)
.then(paths => {
t.is(1, paths.length, '1 bundle created')
return fs.stat(path.join(paths[0], 'my-package'))
}).then(stats => t.true(stats.isFile(), 'The executableName-based filename should exist'))
return util.assertFile(t, path.join(paths[0], 'my-package'), 'The executableName-based filename should exist')
})
})
util.packagerTest('fails with invalid version', util.invalidOptionTest({

View File

@@ -44,18 +44,20 @@ function electron0374Test (testName, testFunction) {
return testWrapper.apply(null, [testName, el0374Opts, testFunction].concat(extraArgs))
}
function getHelperExecutablePath (helperName) {
return path.join(`${helperName}.app`, 'Contents', 'MacOS', helperName)
function getFrameworksPath (prefix, appName) {
return path.join(prefix, `${appName}.app`, 'Contents', 'Frameworks')
}
function getHelperAppPath (prefix, appName, helperSuffix) {
return path.join(getFrameworksPath(prefix, appName), `${appName} ${helperSuffix}.app`)
}
function getHelperExecutablePath (prefix, appName, helperSuffix) {
return path.join(getHelperAppPath(prefix, appName, helperSuffix), 'Contents', 'MacOS', `${appName} ${helperSuffix}`)
}
function parseInfoPlist (t, opts, basePath) {
const plistPath = path.join(basePath, `${opts.name}.app`, 'Contents', 'Info.plist')
return fs.stat(plistPath)
.then(stats => {
t.true(stats.isFile(), 'The expected Info.plist file should exist')
return fs.readFile(plistPath, 'utf8')
}).then(file => plist.parse(file))
return util.parsePlist(t, path.join(basePath, `${opts.name}.app`))
}
function packageAndParseInfoPlist (t, opts) {
@@ -63,9 +65,23 @@ function packageAndParseInfoPlist (t, opts) {
.then(paths => parseInfoPlist(t, opts, paths[0]))
}
function assertPlistStringValue (t, obj, property, value, message) {
t.is(obj[property], value, message)
t.is(typeof obj[property], 'string', `${property} should be a string`)
}
function assertCFBundleIdentifierValue (t, obj, value, message) {
assertPlistStringValue(t, obj, 'CFBundleIdentifier', value, message)
t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
}
function assertHelper (t, prefix, appName, helperSuffix) {
return util.assertDirectory(t, getHelperAppPath(prefix, appName, helperSuffix), `The ${helperSuffix}.app should reflect sanitized opts.name`)
.then(() => util.assertFile(t, getHelperExecutablePath(prefix, appName, helperSuffix), `The ${helperSuffix}.app executable should reflect sanitized opts.name`))
}
function helperAppPathsTest (t, baseOpts, extraOpts, expectedName) {
const opts = Object.assign(baseOpts, extraOpts)
let frameworksPath
if (!expectedName) {
expectedName = opts.name
@@ -73,22 +89,13 @@ function helperAppPathsTest (t, baseOpts, extraOpts, expectedName) {
return packager(opts)
.then(paths => {
frameworksPath = path.join(paths[0], `${expectedName}.app`, 'Contents', 'Frameworks')
// main Helper.app is already tested in basic test suite; test its executable and the other helpers
return fs.stat(path.join(frameworksPath, getHelperExecutablePath(`${expectedName} Helper`)))
}).then(stats => {
t.true(stats.isFile(), 'The Helper.app executable should reflect sanitized opts.name')
return fs.stat(path.join(frameworksPath, `${expectedName} Helper EH.app`))
}).then(stats => {
t.true(stats.isDirectory(), 'The Helper EH.app should reflect sanitized opts.name')
return fs.stat(path.join(frameworksPath, getHelperExecutablePath(`${expectedName} Helper EH`)))
}).then(stats => {
t.true(stats.isFile(), 'The Helper EH.app executable should reflect sanitized opts.name')
return fs.stat(path.join(frameworksPath, `${expectedName} Helper NP.app`))
}).then(stats => {
t.true(stats.isDirectory(), 'The Helper NP.app should reflect sanitized opts.name')
return fs.stat(path.join(frameworksPath, getHelperExecutablePath(`${expectedName} Helper NP`)))
}).then(stats => t.true(stats.isFile(), 'The Helper NP.app executable should reflect sanitized opts.name'))
const helpers = [
'Helper',
'Helper EH',
'Helper NP'
]
return Promise.all(helpers.map(helper => assertHelper(t, paths[0], expectedName, helper)))
})
}
function iconTest (t, opts, icon, iconPath) {
@@ -101,9 +108,7 @@ function iconTest (t, opts, icon, iconPath) {
resourcesPath = generatedResourcesPath
const outputPath = resourcesPath.replace(`${path.sep}${util.generateResourcesPath(opts)}`, '')
return parseInfoPlist(t, opts, outputPath)
}).then(obj => {
return util.areFilesEqual(iconPath, path.join(resourcesPath, obj.CFBundleIconFile))
}).then(equal => t.true(equal, 'installed icon file should be identical to the specified icon file'))
}).then(obj => util.assertFilesEqual(t, iconPath, path.join(resourcesPath, obj.CFBundleIconFile), 'installed icon file should be identical to the specified icon file'))
}
function extendInfoTest (t, baseOpts, extraPathOrParams) {
@@ -116,15 +121,29 @@ function extendInfoTest (t, baseOpts, extraPathOrParams) {
return packageAndParseInfoPlist(t, opts)
.then(obj => {
t.is(obj.TestKeyString, 'String data', 'TestKeyString should come from extendInfo')
assertPlistStringValue(t, obj, 'TestKeyString', 'String data', 'TestKeyString should come from extendInfo')
t.is(obj.TestKeyInt, 12345, 'TestKeyInt should come from extendInfo')
t.is(obj.TestKeyBool, true, 'TestKeyBool should come from extendInfo')
t.deepEqual(obj.TestKeyArray, ['public.content', 'public.data'], 'TestKeyArray should come from extendInfo')
t.deepEqual(obj.TestKeyDict, { Number: 98765, CFBundleVersion: '0.0.0' }, 'TestKeyDict should come from extendInfo')
t.is(obj.CFBundleVersion, opts.buildVersion, 'CFBundleVersion should reflect buildVersion argument')
t.is(obj.CFBundleIdentifier, 'com.electron.extratest', 'CFBundleIdentifier should reflect appBundleId argument')
t.is(obj.LSApplicationCategoryType, 'public.app-category.music', 'LSApplicationCategoryType should reflect appCategoryType argument')
return t.is(obj.CFBundlePackageType, 'APPL', 'CFBundlePackageType should be Electron default')
assertPlistStringValue(t, obj, 'CFBundleVersion', opts.buildVersion, 'CFBundleVersion should reflect buildVersion argument')
assertCFBundleIdentifierValue(t, obj, 'com.electron.extratest', 'CFBundleIdentifier should reflect appBundleId argument')
assertPlistStringValue(t, obj, 'LSApplicationCategoryType', 'public.app-category.music', 'LSApplicationCategoryType should reflect appCategoryType argument')
return assertPlistStringValue(t, obj, 'CFBundlePackageType', 'APPL', 'CFBundlePackageType should be Electron default')
})
}
function darkModeTest (t, baseOpts) {
const opts = Object.assign({}, baseOpts, {
appBundleId: 'com.electron.extratest',
appCategoryType: 'public.app-category.music',
buildVersion: '3.2.1',
darwinDarkModeSupport: true
})
return packageAndParseInfoPlist(t, opts)
.then(obj => {
return t.is(obj.NSRequiresAquaSystemAppearance, false, 'NSRequiresAquaSystemAppearance should be set to false')
})
}
@@ -133,13 +152,8 @@ function binaryNameTest (t, baseOpts, extraOpts, expectedExecutableName, expecte
const appName = expectedAppName || expectedExecutableName || opts.name
const executableName = expectedExecutableName || opts.name
let binaryPath
return packager(opts)
.then(paths => {
binaryPath = path.join(paths[0], `${appName}.app`, 'Contents', 'MacOS')
return fs.stat(path.join(binaryPath, executableName))
}).then(stats => t.true(stats.isFile(), 'The binary should reflect a sanitized opts.name'))
.then(paths => util.assertFile(t, path.join(paths[0], `${appName}.app`, 'Contents', 'MacOS', executableName), 'The binary should reflect a sanitized opts.name'))
}
function appVersionTest (t, opts, appVersion, buildVersion) {
@@ -148,10 +162,8 @@ function appVersionTest (t, opts, appVersion, buildVersion) {
return packageAndParseInfoPlist(t, opts)
.then(obj => {
t.is(obj.CFBundleVersion, '' + opts.buildVersion, 'CFBundleVersion should reflect buildVersion')
t.is(obj.CFBundleShortVersionString, '' + opts.appVersion, 'CFBundleShortVersionString should reflect appVersion')
t.is(typeof obj.CFBundleVersion, 'string', 'CFBundleVersion should be a string')
return t.is(typeof obj.CFBundleShortVersionString, 'string', 'CFBundleShortVersionString should be a string')
assertPlistStringValue(t, obj, 'CFBundleVersion', '' + opts.buildVersion, 'CFBundleVersion should reflect buildVersion')
return assertPlistStringValue(t, obj, 'CFBundleShortVersionString', '' + opts.appVersion, 'CFBundleShortVersionString should reflect appVersion')
})
}
@@ -165,18 +177,14 @@ function appBundleTest (t, opts, appBundleId) {
return packageAndParseInfoPlist(t, opts)
.then(obj => {
t.is(obj.CFBundleDisplayName, opts.name, 'CFBundleDisplayName should reflect opts.name')
t.is(obj.CFBundleName, opts.name, 'CFBundleName should reflect opts.name')
t.is(obj.CFBundleIdentifier, appBundleIdentifier, 'CFBundleName should reflect opts.appBundleId or fallback to default')
t.is(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string')
t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string')
t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string')
return t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
assertPlistStringValue(t, obj, 'CFBundleDisplayName', opts.name, 'CFBundleDisplayName should reflect opts.name')
assertPlistStringValue(t, obj, 'CFBundleName', opts.name, 'CFBundleName should reflect opts.name')
return assertCFBundleIdentifierValue(t, obj, appBundleIdentifier, 'CFBundleName should reflect opts.appBundleId or fallback to default')
})
}
function appHelpersBundleTest (t, opts, helperBundleId, appBundleId) {
let tempPath, plistPath
let frameworksPath
if (helperBundleId) {
opts.helperBundleId = helperBundleId
@@ -190,53 +198,25 @@ function appHelpersBundleTest (t, opts, helperBundleId, appBundleId) {
return packager(opts)
.then(paths => {
tempPath = paths[0]
plistPath = path.join(tempPath, opts.name + '.app', 'Contents', 'Frameworks', opts.name + ' Helper.app', 'Contents', 'Info.plist')
return fs.stat(plistPath)
}).then(stats => {
t.true(stats.isFile(), 'The expected Info.plist file should exist in helper app')
return fs.readFile(plistPath, 'utf8')
}).then(file => {
const obj = plist.parse(file)
t.is(obj.CFBundleName, opts.name, 'CFBundleName should reflect opts.name in helper app')
t.is(obj.CFBundleIdentifier, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')
t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string in helper app')
t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string in helper app')
t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
frameworksPath = path.join(paths[0], `${opts.name}.app`, 'Contents', 'Frameworks')
return util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper.app`))
}).then(obj => {
assertPlistStringValue(t, obj, 'CFBundleName', opts.name, 'CFBundleName should reflect opts.name in helper app')
assertCFBundleIdentifierValue(t, obj, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')
// check helper EH
plistPath = path.join(tempPath, opts.name + '.app', 'Contents', 'Frameworks', opts.name + ' Helper EH.app', 'Contents', 'Info.plist')
return fs.stat(plistPath)
}).then(stats => {
t.true(stats.isFile(), 'The expected Info.plist file should exist in helper EH app')
return fs.readFile(plistPath, 'utf8')
}).then(file => {
const obj = plist.parse(file)
t.is(obj.CFBundleName, opts.name + ' Helper EH', 'CFBundleName should reflect opts.name in helper EH app')
t.is(obj.CFBundleDisplayName, opts.name + ' Helper EH', 'CFBundleDisplayName should reflect opts.name in helper EH app')
t.is(obj.CFBundleExecutable, opts.name + ' Helper EH', 'CFBundleExecutable should reflect opts.name in helper EH app')
t.is(obj.CFBundleIdentifier, helperBundleIdentifier + '.EH', 'CFBundleName should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper EH app')
t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string in helper EH app')
t.is(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string in helper EH app')
t.is(typeof obj.CFBundleExecutable, 'string', 'CFBundleExecutable should be a string in helper EH app')
t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string in helper EH app')
t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
return util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper EH.app`))
}).then(obj => {
assertPlistStringValue(t, obj, 'CFBundleName', opts.name + ' Helper EH', 'CFBundleName should reflect opts.name in helper EH app')
assertPlistStringValue(t, obj, 'CFBundleDisplayName', opts.name + ' Helper EH', 'CFBundleDisplayName should reflect opts.name in helper EH app')
assertPlistStringValue(t, obj, 'CFBundleExecutable', opts.name + ' Helper EH', 'CFBundleExecutable should reflect opts.name in helper EH app')
assertCFBundleIdentifierValue(t, obj, `${helperBundleIdentifier}.EH`, 'CFBundleName should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper EH app')
// check helper NP
plistPath = path.join(tempPath, opts.name + '.app', 'Contents', 'Frameworks', opts.name + ' Helper NP.app', 'Contents', 'Info.plist')
return fs.stat(plistPath)
}).then(stats => {
t.true(stats.isFile(), 'The expected Info.plist file should exist in helper NP app')
return fs.readFile(plistPath, 'utf8')
}).then(file => {
const obj = plist.parse(file)
t.is(obj.CFBundleName, opts.name + ' Helper NP', 'CFBundleName should reflect opts.name in helper NP app')
t.is(obj.CFBundleDisplayName, opts.name + ' Helper NP', 'CFBundleDisplayName should reflect opts.name in helper NP app')
t.is(obj.CFBundleExecutable, opts.name + ' Helper NP', 'CFBundleExecutable should reflect opts.name in helper NP app')
t.is(obj.CFBundleIdentifier, helperBundleIdentifier + '.NP', 'CFBundleName should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper NP app')
t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string in helper NP app')
t.is(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string in helper NP app')
t.is(typeof obj.CFBundleExecutable, 'string', 'CFBundleExecutable should be a string in helper NP app')
t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string in helper NP app')
return t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
return util.parsePlist(t, path.join(frameworksPath, `${opts.name} Helper NP.app`))
}).then(obj => {
assertPlistStringValue(t, obj, 'CFBundleName', opts.name + ' Helper NP', 'CFBundleName should reflect opts.name in helper NP app')
assertPlistStringValue(t, obj, 'CFBundleDisplayName', opts.name + ' Helper NP', 'CFBundleDisplayName should reflect opts.name in helper NP app')
assertPlistStringValue(t, obj, 'CFBundleExecutable', opts.name + ' Helper NP', 'CFBundleExecutable should reflect opts.name in helper NP app')
return assertCFBundleIdentifierValue(t, obj, helperBundleIdentifier + '.NP', 'CFBundleName should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper NP app')
})
}
@@ -258,6 +238,7 @@ if (!(process.env.CI && process.platform === 'win32')) {
darwinTest('extendInfo by filename test', extendInfoTest, extraInfoPath)
darwinTest('extendInfo by params test', extendInfoTest, extraInfoParams)
darwinTest('mojave dark mode test: should enable dark mode', darkModeTest)
darwinTest('protocol/protocol-name argument test', (t, opts) => {
opts.protocols = [
@@ -327,11 +308,9 @@ if (!(process.env.CI && process.platform === 'win32')) {
return packager(opts)
.then(paths => {
appPath = path.join(paths[0], opts.name + '.app')
return fs.stat(appPath)
}).then(stats => {
t.true(stats.isDirectory(), 'The expected .app directory should exist')
return exec(`codesign -v ${appPath}`)
}).then(
return util.assertDirectory(t, appPath, 'The expected .app directory should exist')
}).then(() => exec(`codesign -v ${appPath}`))
.then(
(stdout, stderr) => t.pass('codesign should verify successfully'),
err => {
const notFound = err && err.code === 127
@@ -353,26 +332,14 @@ if (!(process.env.CI && process.platform === 'win32')) {
const appBundleIdentifier = 'com.electron.username-package-name'
const expectedSanitizedName = '@username-package-name'
let plistPath
opts.name = '@username/package-name'
return packager(opts)
.then(paths => {
plistPath = path.join(paths[0], `${expectedSanitizedName}.app`, 'Contents', 'Info.plist')
return fs.stat(plistPath)
}).then(stats => {
t.true(stats.isFile(), 'The expected Info.plist file should exist')
return fs.readFile(plistPath, 'utf8')
}).then(file => {
const obj = plist.parse(file)
t.is(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string')
t.is(obj.CFBundleDisplayName, opts.name, 'CFBundleDisplayName should reflect opts.name')
t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string')
t.is(obj.CFBundleName, expectedSanitizedName, 'CFBundleName should reflect a sanitized opts.name')
t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string')
t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
return t.is(obj.CFBundleIdentifier, appBundleIdentifier, 'CFBundleIdentifier should reflect the sanitized opts.name')
.then(paths => util.parsePlist(t, path.join(paths[0], `${expectedSanitizedName}.app`)))
.then(obj => {
assertPlistStringValue(t, obj, 'CFBundleDisplayName', opts.name, 'CFBundleDisplayName should reflect opts.name')
assertPlistStringValue(t, obj, 'CFBundleName', expectedSanitizedName, 'CFBundleName should reflect a sanitized opts.name')
return assertCFBundleIdentifierValue(t, obj, appBundleIdentifier, 'CFBundleIdentifier should reflect the sanitized opts.name')
})
})
@@ -382,8 +349,8 @@ if (!(process.env.CI && process.platform === 'win32')) {
darwinTest('infer app version from package.json test', (t, opts) =>
packageAndParseInfoPlist(t, opts)
.then(obj => {
t.is(obj.CFBundleVersion, '4.99.101', 'CFBundleVersion should reflect package.json version')
return t.is(obj.CFBundleShortVersionString, '4.99.101', 'CFBundleShortVersionString should reflect package.json version')
assertPlistStringValue(t, obj, 'CFBundleVersion', '4.99.101', 'CFBundleVersion should reflect package.json version')
return assertPlistStringValue(t, obj, 'CFBundleShortVersionString', '4.99.101', 'CFBundleShortVersionString should reflect package.json version')
})
)
@@ -392,7 +359,7 @@ if (!(process.env.CI && process.platform === 'win32')) {
opts.appCategoryType = appCategoryType
return packageAndParseInfoPlist(t, opts)
.then(obj => t.is(obj.LSApplicationCategoryType, appCategoryType, 'LSApplicationCategoryType should reflect opts.appCategoryType'))
.then(obj => assertPlistStringValue(t, obj, 'LSApplicationCategoryType', appCategoryType, 'LSApplicationCategoryType should reflect opts.appCategoryType'))
})
darwinTest('app bundle test', appBundleTest, 'com.electron.basetest')
@@ -405,14 +372,9 @@ if (!(process.env.CI && process.platform === 'win32')) {
return packager(opts)
.then(paths => {
frameworkPath = path.join(paths[0], `${opts.name}.app`, 'Contents', 'Frameworks', 'Electron Framework.framework')
return fs.stat(frameworkPath)
}).then(stats => {
t.true(stats.isDirectory(), 'Expected Electron Framework.framework to be a directory')
return fs.lstat(path.join(frameworkPath, 'Electron Framework'))
}).then(stats => {
t.true(stats.isSymbolicLink(), 'Expected Electron Framework.framework/Electron Framework to be a symlink')
return fs.lstat(path.join(frameworkPath, 'Versions', 'Current'))
}).then(stats => t.true(stats.isSymbolicLink(), 'Expected Electron Framework.framework/Versions/Current to be a symlink'))
return util.assertDirectory(t, frameworkPath, 'Expected Electron Framework.framework to be a directory')
}).then(() => util.assertSymlink(t, path.join(frameworkPath, 'Electron Framework'), 'Expected Electron Framework.framework/Electron Framework to be a symlink'))
.then(() => util.assertSymlink(t, path.join(frameworkPath, 'Versions', 'Current'), 'Expected Electron Framework.framework/Versions/Current to be a symlink'))
})
darwinTest('app helpers bundle test', appHelpersBundleTest, 'com.electron.basetest.helper')
@@ -421,6 +383,23 @@ if (!(process.env.CI && process.platform === 'win32')) {
darwinTest('app helpers bundle helper-bundle-id fallback to app-bundle-id (w/ special characters) test', appHelpersBundleTest, null, 'com.electron."bãśè tëßt!!@#$%^&*()?\'')
darwinTest('app helpers bundle helper-bundle-id & app-bundle-id fallback test', appHelpersBundleTest)
darwinTest('EH/NP helpers do not exist', (t, baseOpts) => {
const helpers = [
'Helper EH',
'Helper NP'
]
const opts = Object.assign({}, baseOpts, {
afterExtract: [(buildPath, electronVersion, platform, arch, cb) => {
return Promise.all(helpers.map(helper => fs.remove(getHelperAppPath(buildPath, 'Electron', helper)))).then(() => cb()) // eslint-disable-line promise/no-callback-in-promise
}]
})
return packager(opts)
.then(paths => {
return Promise.all(helpers.map(helper => util.assertPathNotExists(t, getHelperAppPath(paths[0], opts.name, helper), `${helper} should not exist`)))
})
})
darwinTest('appCopyright/NSHumanReadableCopyright test', (t, baseOpts) => {
const copyright = 'Copyright © 20032015 Organization. All rights reserved.'
const opts = Object.assign({}, baseOpts, {appCopyright: copyright})
@@ -436,10 +415,7 @@ if (!(process.env.CI && process.platform === 'win32')) {
return packager(opts)
.then(paths => {
appPath = path.join(paths[0], 'Electron.app')
return fs.stat(appPath)
}).then(stats => {
t.true(stats.isDirectory(), 'The Electron.app folder exists')
return fs.stat(path.join(appPath, 'Contents', 'MacOS', 'Electron'))
}).then(stats => t.true(stats.isFile(), 'The Electron.app/Contents/MacOS/Electron binary exists'))
return util.assertDirectory(t, appPath, 'The Electron.app folder exists')
}).then(() => util.assertFile(t, path.join(appPath, 'Contents', 'MacOS', 'Electron'), 'The Electron.app/Contents/MacOS/Electron binary exists'))
})
}

View File

@@ -20,59 +20,41 @@ function ignoreTest (t, opts, ignorePattern, ignoredFile) {
return fs.copy(opts.dir, targetDir, {
dereference: false,
filter: ignore.userIgnoreFilter(opts)
}).then(() => fs.pathExists(path.join(targetDir, 'package.json')))
.then(exists => {
t.true(exists, 'The expected output directory should exist and contain files')
return fs.pathExists(path.join(targetDir, ignoredFile))
}).then(exists => t.false(exists, `Ignored file '${ignoredFile}' should not exist in copied directory`))
}).then(() => util.assertPathExists(t, path.join(targetDir, 'package.json'), 'The expected output directory should exist and contain files'))
.then(() => util.assertPathNotExists(t, path.join(targetDir, ignoredFile), `Ignored file '${ignoredFile}' should not exist in copied directory`))
}
function assertOutDirIgnored (t, opts, pathPrefix, existingDirectoryPath, pathToIgnore, ignoredBasenameToCheck) {
return fs.copy(util.fixtureSubdir('basic'), t.context.workDir, {
dereference: true,
stopOnErr: true,
filter: file => path.basename(file) !== 'node_modules'
}).then(() => fs.ensureDir(existingDirectoryPath))
// create file to ensure that directory will be not ignored because it's empty
.then(() => fs.writeFile(pathToIgnore, '')).then(() => packager(opts))
.then(() => util.assertPathNotExists(t, path.join(pathPrefix, common.generateFinalBasename(opts), util.generateResourcesPath(opts), 'app', ignoredBasenameToCheck), 'Out dir must not exist in output app directory'))
}
function ignoreOutDirTest (t, opts, distPath) {
opts.name = 'ignoreOutDirTest'
opts.dir = t.context.workDir
opts.name = 'ignoreOutDirTest'
// create out dir before packager (real world issue - when second run includes unignored out dir)
// we don't use path.join here to avoid normalizing
const outDir = opts.dir + path.sep + distPath
opts.out = outDir
opts.out = opts.dir + path.sep + distPath
return fs.copy(util.fixtureSubdir('basic'), t.context.workDir, {
dereference: true,
stopOnErr: true,
filter: file => { return path.basename(file) !== 'node_modules' }
}).then(() =>
// create out dir before packager (real world issue - when second run includes unignored out dir)
fs.ensureDir(outDir)
).then(() =>
// create file to ensure that directory will be not ignored because empty
fs.open(path.join(outDir, 'ignoreMe'), 'w')
).then(fd => fs.close(fd))
.then(() => packager(opts))
.then(() => fs.pathExists(path.join(outDir, common.generateFinalBasename(opts), util.generateResourcesPath(opts), 'app', path.basename(outDir))))
.then(exists => t.false(exists, 'Out dir must not exist in output app directory'))
return assertOutDirIgnored(t, opts, opts.out, opts.out, path.join(opts.out, 'ignoreMe'), path.basename(opts.out))
}
function ignoreImplicitOutDirTest (t, opts) {
opts.name = 'ignoreImplicitOutDirTest'
opts.dir = t.context.workDir
opts.name = 'ignoreImplicitOutDirTest'
delete opts.out
const testFilename = 'ignoreMe'
let previousPackedResultDir
const previousPackedResultDir = path.join(opts.dir, `${common.sanitizeAppName(opts.name)}-linux-ia32`)
return fs.copy(util.fixtureSubdir('basic'), t.context.workDir, {
dereference: true,
stopOnErr: true,
filter: file => { return path.basename(file) !== 'node_modules' }
}).then(() => {
previousPackedResultDir = path.join(opts.dir, `${common.sanitizeAppName(opts.name)}-linux-ia32`)
return fs.ensureDir(previousPackedResultDir)
}).then(() =>
// create file to ensure that directory will be not ignored because empty
fs.open(path.join(previousPackedResultDir, testFilename), 'w')
).then(fd => fs.close(fd))
.then(() => packager(opts))
.then(() => fs.pathExists(path.join(opts.dir, common.generateFinalBasename(opts), util.generateResourcesPath(opts), 'app', testFilename)))
.then(exists => t.false(exists, 'Out dir must not exist in output app directory'))
return assertOutDirIgnored(t, opts, opts.dir, previousPackedResultDir, path.join(previousPackedResultDir, testFilename), testFilename)
}
test('generateIgnores ignores the generated temporary directory only on Linux', t => {

View File

@@ -1,9 +1,7 @@
'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')) {
@@ -33,26 +31,20 @@ if (!(process.env.CI && process.platform === 'win32')) {
})
util.packagerTest('update Login Helper if it exists', (t, baseOpts) => {
let helperPath
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)
helperPath = path.join(paths[0], `${masOpts.name}.app`, 'Contents', 'Library', 'LoginItems', `${helperName}.app`)
contentsPath = path.join(helperPath, 'Contents')
return util.assertPathExists(t, helperPath, 'renamed Login Helper app exists')
}).then(() => util.parsePlist(t, helperPath))
.then(plistData => {
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'))
return util.assertPathExists(t, path.join(contentsPath, 'MacOS', helperName), 'renamed Login Helper executable exists')
})
})
}

View File

@@ -1,6 +1,5 @@
'use strict'
const fs = require('fs-extra')
const path = require('path')
const prune = require('../prune')
const test = require('ava')
@@ -10,15 +9,13 @@ function checkDependency (t, resourcesPath, moduleName, moduleExists) {
const assertion = moduleExists ? 'should' : 'should NOT'
const message = `module dependency '${moduleName}' ${assertion} exist under app/node_modules`
const modulePath = path.join(resourcesPath, 'app', 'node_modules', moduleName)
return fs.pathExists(modulePath)
.then(exists => t.is(moduleExists, exists, message))
return util.assertPathExistsCustom(t, modulePath, moduleExists, message)
.then(() => modulePath)
}
function assertDependencyExists (t, resourcesPath, moduleName) {
return checkDependency(t, resourcesPath, moduleName, true)
.then(modulePath => fs.stat(modulePath))
.then(stats => t.true(stats.isDirectory(), 'module is a directory'))
.then(modulePath => util.assertDirectory(t, modulePath, 'module is a directory'))
}
function createPruneOptionTest (t, baseOpts, prune, testMessage) {
@@ -56,10 +53,13 @@ util.testSinglePlatform('prune electron in dependencies', (t, baseOpts) => {
util.testSinglePlatform('prune: false test', createPruneOptionTest, false,
'package.json devDependency should exist under app/node_modules')
test('isModule only detects modules inside a node_modules parent folder', t =>
test('isModule properly detects module folders', t =>
prune.isModule(util.fixtureSubdir(path.join('prune-is-module', 'node_modules', 'module')))
.then(isModule => {
t.true(isModule, 'module folder should be detected as module')
return prune.isModule(util.fixtureSubdir(path.join('prune-is-module', 'node_modules', 'module', 'not-module')))
}).then(isModule => t.false(isModule, 'not-module folder should not be detected as module'))
}).then(isModule => {
t.false(isModule, 'not-module subfolder should not be detected as module')
return prune.isModule(util.fixtureSubdir(path.join('prune-is-module', 'node_modules', '@user', 'namespaced')))
}).then(isModule => t.true(isModule, '@user/namespaced folder should be detected as module'))
)

View File

@@ -93,34 +93,6 @@ test('fails with invalid platform', util.invalidOptionTest({
platform: 'dos'
}))
test('hostArch detects incorrectly configured armv7l Node', t => {
sinon.stub(targets, 'unameArch').returns('armv7l')
sinon.stub(process, 'arch').value('arm')
sinon.stub(process, 'config').value({variables: {arm_version: '6'}})
t.is(targets.hostArch(), 'armv7l')
sinon.restore()
})
test('hostArch detects correctly configured armv7l Node', t => {
sinon.stub(process, 'arch').value('arm')
sinon.stub(process, 'config').value({variables: {arm_version: '7'}})
t.is(targets.hostArch(), 'armv7l')
sinon.restore()
})
test('hostArch cannot determine ARM version', t => {
sinon.stub(process, 'arch').value('arm')
sinon.stub(process, 'config').value({variables: {arm_version: '99'}})
t.is(targets.hostArch(), 'arm')
sinon.restore()
})
testMultiTarget('invalid official combination', {arch: 'ia32', platform: 'darwin'}, 0, 'Package should not be generated for invalid official combination')
testMultiTarget('platform=linux and arch=arm64 with a supported official Electron version', {arch: 'arm64', platform: 'linux', electronVersion: '1.8.0'}, 1, 'Package should be generated for arm64')
testMultiTarget('platform=linux and arch=arm64 with an unsupported official Electron version', {arch: 'arm64', platform: 'linux'}, 0, 'Package should not be generated for arm64')

View File

@@ -1,7 +1,6 @@
'use strict'
const config = require('./config.json')
const fs = require('fs-extra')
const packager = require('..')
const path = require('path')
const test = require('ava')
@@ -173,38 +172,38 @@ test('win32metadata defaults', t => {
t.is(rcOpts['version-string'].ProductName, opts.name, 'default ProductName')
})
util.packagerTest('win32 executable name is based on sanitized app name', (t, opts) => {
Object.assign(opts, win32Opts, { name: '@username/package-name' })
function win32Test (description, extraOpts, executableBasename, executableMessage) {
util.packagerTest(description, (t, opts) => {
Object.assign(opts, win32Opts, extraOpts)
return packager(opts)
.then(paths => {
t.is(1, paths.length, '1 bundle created')
const appExePath = path.join(paths[0], '@username-package-name.exe')
return fs.pathExists(appExePath)
}).then(exists => t.true(exists, 'The sanitized EXE filename should exist'))
})
return packager(opts)
.then(paths => {
t.is(1, paths.length, '1 bundle created')
return util.assertPathExists(t, path.join(paths[0], `${executableBasename}.exe`), executableMessage)
})
})
}
util.packagerTest('win32 executable name uses executableName when available', (t, opts) => {
Object.assign(opts, win32Opts, { name: 'PackageName', executableName: 'my-package' })
win32Test(
'win32 executable name is based on sanitized app name',
{ name: '@username/package-name' },
'@username-package-name',
'The sanitized EXE filename should exist'
)
return packager(opts)
.then(paths => {
t.is(1, paths.length, '1 bundle created')
const appExePath = path.join(paths[0], 'my-package.exe')
return fs.pathExists(appExePath)
}).then(exists => t.true(exists, 'the executableName-based filename should exist'))
})
win32Test(
'win32 executable name uses executableName when available',
{ name: 'PackageName', executableName: 'my-package' },
'my-package',
'the executableName-based filename should exist'
)
util.packagerTest('win32 icon set', (t, opts) => {
Object.assign(opts, win32Opts, { executableName: 'iconTest', arch: 'ia32', icon: path.join(__dirname, 'fixtures', 'monochrome') })
return packager(opts)
.then(paths => {
t.is(1, paths.length, '1 bundle created')
const appExePath = path.join(paths[0], 'iconTest.exe')
return fs.pathExists(appExePath)
}).then(exists => t.true(exists, 'the Electron executable should exist'))
})
win32Test(
'win32 icon set',
{ executableName: 'iconTest', arch: 'ia32', icon: path.join(__dirname, 'fixtures', 'monochrome') },
'iconTest',
'the Electron executable should exist'
)
test('win32 build version sets FileVersion test', setFileVersionTest('2.3.4.5'))
test('win32 app version sets ProductVersion test', setProductVersionTest('5.4.3.2'))