From fa519cf3419140c17b80acb3000e5df6c5932b72 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Mon, 7 May 2018 23:38:46 -0700 Subject: [PATCH 1/3] Drop support for Node < 6 --- .travis.yml | 6 +----- cli.js | 5 +++-- docs/api.md | 6 +++--- ignore.js | 4 ++-- infer.js | 7 ++----- mac.js | 6 +++--- package.json | 6 +++--- prune.js | 6 ++---- readme.md | 2 +- targets.js | 4 ++-- test/_setup.js | 2 +- test/_util.js | 8 ++------ test/ci/appveyor.yml | 6 +----- test/darwin.js | 2 +- test/ignore.js | 5 ++--- test/targets.js | 16 ++++++++-------- 16 files changed, 37 insertions(+), 54 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9f25deb1..47a6bcc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,9 @@ dist: trusty osx_image: xcode8 language: node_js node_js: -- '4' - '6' - '8' -- '9' -matrix: - allow_failures: - - node_js: '9' +- '10' cache: - apt: true - directories: diff --git a/cli.js b/cli.js index f481b095..82f45a19 100755 --- a/cli.js +++ b/cli.js @@ -2,10 +2,11 @@ 'use strict' +var packageJSON = require('./package.json') var semver = require('semver') -if (semver.lt(process.versions.node, '4.0.0')) { +if (!semver.satisfies(process.versions.node, packageJSON.engines.node)) { console.error('CANNOT RUN WITH NODE ' + process.versions.node) - console.error('Electron Packager requires Node 4.0 or above.') + console.error('Electron Packager requires Node ' + packageJSON.engines.node + '.') process.exit(1) } diff --git a/docs/api.md b/docs/api.md index 59e6e84e..734aa340 100644 --- a/docs/api.md +++ b/docs/api.md @@ -47,7 +47,7 @@ If you need the functions called serially, there is a utility function provided: ```javascript const packager = require('electron-packager') -const serialHooks = require('electron-packager/hooks').serialHooks +const { serialHooks } = require('electron-packager/hooks') packager({ // ... @@ -87,7 +87,7 @@ If you need the functions called serially, there is a utility function provided: ```javascript const packager = require('electron-packager') -const serialHooks = require('electron-packager/hooks').serialHooks +const { serialHooks } = require('electron-packager/hooks') packager({ // ... @@ -128,7 +128,7 @@ If you need the functions called serially, there is a utility function provided: ```javascript const packager = require('electron-packager') -const serialHooks = require('electron-packager/hooks').serialHooks +const { serialHooks } = require('electron-packager/hooks') packager({ // ... diff --git a/ignore.js b/ignore.js index 3fb6f5ea..ab79a478 100644 --- a/ignore.js +++ b/ignore.js @@ -69,11 +69,11 @@ function userIgnoreFilter (opts) { const pruner = opts.prune ? new prune.Pruner(opts.dir) : null return function filter (file) { - if (outIgnores.indexOf(file) !== -1) { + if (outIgnores.includes(file)) { return false } - let name = file.split(path.resolve(opts.dir))[1] + let name = path.resolve(file).split(path.resolve(opts.dir))[1] if (path.sep === '\\') { name = common.normalizePath(name) diff --git a/infer.js b/infer.js index 5652bc76..0ed91352 100644 --- a/infer.js +++ b/infer.js @@ -33,10 +33,7 @@ function errorMessageForProperty (prop) { } function getVersion (opts, electronProp) { - // Destructured assignments are added in Node 6 - const splitProp = electronProp.prop.split('.') - const depType = splitProp[0] - const packageName = splitProp[1] + const [depType, packageName] = electronProp.prop.split('.') const src = electronProp.src if (packageName === 'electron-prebuilt-compile') { // electron-prebuilt-compile cannot be resolved because `main` does not point @@ -107,7 +104,7 @@ module.exports = function getMetadataFromPackageJSON (platforms, opts, dir) { ]) } - if (platforms.indexOf('win32') !== -1 && !(opts.win32metadata && opts.win32metadata.CompanyName)) { + if (platforms.includes('win32') && !(opts.win32metadata && opts.win32metadata.CompanyName)) { props.push('author') } diff --git a/mac.js b/mac.js index 9461aeca..d12d1891 100644 --- a/mac.js +++ b/mac.js @@ -6,7 +6,7 @@ const debug = require('debug')('electron-packager') const fs = require('fs-extra') const path = require('path') const plist = require('plist') -const sign = require('electron-osx-sign').signAsync +const { signAsync } = require('electron-osx-sign') class MacApp extends App { constructor (opts, templatePath) { @@ -293,8 +293,8 @@ class MacApp extends App { if (osxSignOpt) { const signOpts = createSignOpts(osxSignOpt, platform, this.renamedAppPath, version, this.opts.quiet) debug(`Running electron-osx-sign with the options ${JSON.stringify(signOpts)}`) - return sign(signOpts) - // Although not signed successfully, the application is packed. + return signAsync(signOpts) + // Although not signed successfully, the application is packed. .catch(err => common.warning(`Code sign failed; please retry manually. ${err}`)) } else { return Promise.resolve() diff --git a/package.json b/package.json index 470b25f2..120b59d7 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,13 @@ "electron-download": "^4.1.1", "electron-osx-sign": "^0.4.1", "extract-zip": "^1.0.3", - "fs-extra": "^5.0.0", + "fs-extra": "^6.0.0", "galactus": "^0.2.1", "get-package-info": "^1.0.0", "nodeify": "^1.0.1", "parse-author": "^2.0.0", "pify": "^3.0.0", - "plist": "^2.0.0", + "plist": "^3.0.0", "rcedit": "^1.0.0", "resolve": "^1.1.6", "sanitize-filename": "^1.6.0", @@ -53,7 +53,7 @@ "tempy": "^0.2.1" }, "engines": { - "node": ">= 4.0" + "node": ">= 6.0" }, "scripts": { "codecov": "nyc report --reporter=text-lcov > coverage.lcov && codecov", diff --git a/prune.js b/prune.js index a6b81551..cc9b8ab4 100644 --- a/prune.js +++ b/prune.js @@ -42,8 +42,7 @@ class Pruner { return false } - // Node 6 has Array.prototype.includes - if (ELECTRON_MODULES.indexOf(module.name) !== -1) { + if (ELECTRON_MODULES.includes(module.name)) { common.warning(`Found '${module.name}' but not as a devDependency, pruning anyway`) return false } @@ -58,8 +57,7 @@ class Pruner { function isNodeModuleFolder (pathToCheck) { return path.basename(path.dirname(pathToCheck)) === 'node_modules' || - // TODO: Change to startsWith in Node 6 - (path.basename(path.dirname(pathToCheck))[0] === '@' && path.basename(path.resolve(pathToCheck, `..${path.sep}..`)) === 'node_modules') + (path.basename(path.dirname(pathToCheck)).startsWith('@') && path.basename(path.resolve(pathToCheck, `..${path.sep}..`)) === 'node_modules') } module.exports = { diff --git a/readme.md b/readme.md index 0b10c0c8..1d9e5e9a 100644 --- a/readme.md +++ b/readme.md @@ -58,7 +58,7 @@ It generates executables/bundles for the following **target** platforms: ## Installation -This module requires Node.js 4.0 or higher to run. +This module requires Node.js 6.0 or higher to run. ```sh # for use in npm scripts diff --git a/targets.js b/targets.js index df736235..cfb4a13e 100644 --- a/targets.js +++ b/targets.js @@ -64,7 +64,7 @@ function usingOfficialElectronPackages (opts) { } function validOfficialPlatformArch (opts, platform, arch) { - return officialPlatformArchCombos[platform] && officialPlatformArchCombos[platform].indexOf(arch) !== -1 + return officialPlatformArchCombos[platform] && officialPlatformArchCombos[platform].includes(arch) } function officialLinuxBuildExists (opts, buildVersion) { @@ -87,7 +87,7 @@ module.exports = { if (platform === 'linux') { const excludedArchs = Object.keys(linuxArchBuildVersions) .filter(arch => !officialLinuxBuildExists({electronVersion: electronVersion}, linuxArchBuildVersions[arch])) - return archs.filter(arch => excludedArchs.indexOf(arch) === -1) + return archs.filter(arch => !excludedArchs.includes(arch)) } return archs diff --git a/test/_setup.js b/test/_setup.js index e87d4c7a..52db8960 100644 --- a/test/_setup.js +++ b/test/_setup.js @@ -3,7 +3,7 @@ const common = require('../common') const download = require('../download') const config = require('./config.json') -const exec = require('mz/child_process').exec +const { exec } = require('mz/child_process') const fs = require('fs-extra') const os = require('os') const path = require('path') diff --git a/test/_util.js b/test/_util.js index aa21910e..fc57478f 100644 --- a/test/_util.js +++ b/test/_util.js @@ -124,14 +124,10 @@ module.exports = { electronVersion: config.version } }, - // Rest parameters are added (not behind a feature flag) in Node 6 - testSinglePlatform: function (name, testFunction /*, ...testFunctionArgs */) { - const testFunctionArgs = Array.prototype.slice.call(arguments, 2) + testSinglePlatform: function (name, testFunction, ...testFunctionArgs) { return testSinglePlatform(name, testFunction, testFunctionArgs, false) }, - // Rest parameters are added (not behind a feature flag) in Node 6 - testSinglePlatformParallel: function (name, testFunction /*, ...testFunctionArgs */) { - const testFunctionArgs = Array.prototype.slice.call(arguments, 2) + testSinglePlatformParallel: function (name, testFunction, ...testFunctionArgs) { return testSinglePlatform(name, testFunction, testFunctionArgs, true) }, verifyPackageExistence: function verifyPackageExistence (finalPaths) { diff --git a/test/ci/appveyor.yml b/test/ci/appveyor.yml index 498f383b..6e6fca94 100644 --- a/test/ci/appveyor.yml +++ b/test/ci/appveyor.yml @@ -3,13 +3,9 @@ platform: - x64 environment: matrix: - - nodejs_version: "4" - nodejs_version: "6" - nodejs_version: "8" - - nodejs_version: "9" -matrix: - allow_failures: - - nodejs_version: "9" + - nodejs_version: "10" cache: - 'node_modules' - '%USERPROFILE%\.electron' diff --git a/test/darwin.js b/test/darwin.js index 8b9843e6..02517bd6 100644 --- a/test/darwin.js +++ b/test/darwin.js @@ -1,7 +1,7 @@ 'use strict' const config = require('./config.json') -const exec = require('mz/child_process').exec +const { exec } = require('mz/child_process') const fs = require('fs-extra') const mac = require('../mac') const packager = require('..') diff --git a/test/ignore.js b/test/ignore.js index 0fed0f95..c4e24499 100644 --- a/test/ignore.js +++ b/test/ignore.js @@ -64,11 +64,10 @@ test('generateIgnores ignores the generated temporary directory only on Linux', ignore.generateIgnores(opts) - // Array.prototype.includes is added (not behind a feature flag) in Node 6 if (process.platform === 'linux') { - t.false(opts.ignore.indexOf(expected) === -1, 'temporary dir in opts.ignore') + t.true(opts.ignore.includes(expected), 'temporary dir in opts.ignore') } else { - t.true(opts.ignore.indexOf(expected) === -1, 'temporary dir not in opts.ignore') + t.false(opts.ignore.includes(expected), 'temporary dir not in opts.ignore') } }) diff --git a/test/targets.js b/test/targets.js index 6725e7d7..e78f9faa 100644 --- a/test/targets.js +++ b/test/targets.js @@ -39,17 +39,17 @@ test('allOfficialArchsForPlatformAndVersion returns the correct arches for a kno }) test('allOfficialArchsForPlatformAndVersion returns arm64 when the correct version is specified', t => { - t.not(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.0').indexOf('arm64'), -1, - 'should be found when version is >= 1.8.0') - t.is(targets.allOfficialArchsForPlatformAndVersion('linux', '1.7.0').indexOf('arm64'), -1, - 'should not be found when version is < 1.8.0') + t.true(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.0').includes('arm64'), + 'should be found when version is >= 1.8.0') + t.false(targets.allOfficialArchsForPlatformAndVersion('linux', '1.7.0').includes('arm64'), + 'should not be found when version is < 1.8.0') }) test('allOfficialArchsForPlatformAndVersion returns mips64el when the correct version is specified', t => { - t.not(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.2').indexOf('mips64el'), -1, - 'should be found when version is >= 1.8.2-beta.5') - t.is(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.0').indexOf('mips64el'), -1, - 'should not be found when version is < 1.8.2-beta.5') + t.true(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.2').includes('mips64el'), + 'should be found when version is >= 1.8.2-beta.5') + t.false(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.0').includes('mips64el'), + 'should not be found when version is < 1.8.2-beta.5') }) test('validateListFromOptions does not take non-Array/String values', t => { From 20d946240ef4d812efad248297362af3eaf11e08 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 13 Sep 2018 00:17:24 -0700 Subject: [PATCH 2/3] More package upgrades --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 120b59d7..b63c0bb0 100644 --- a/package.json +++ b/package.json @@ -18,22 +18,22 @@ "homepage": "https://github.com/electron-userland/electron-packager", "dependencies": { "asar": "^0.14.0", - "debug": "^3.0.0", + "debug": "^4.0.1", "electron-download": "^4.1.1", "electron-osx-sign": "^0.4.1", "extract-zip": "^1.0.3", - "fs-extra": "^6.0.0", + "fs-extra": "^7.0.0", "galactus": "^0.2.1", "get-package-info": "^1.0.0", "nodeify": "^1.0.1", "parse-author": "^2.0.0", - "pify": "^3.0.0", + "pify": "^4.0.0", "plist": "^3.0.0", "rcedit": "^1.0.0", "resolve": "^1.1.6", "sanitize-filename": "^1.6.0", "semver": "^5.3.0", - "yargs-parser": "^10.0.0" + "yargs-parser": "^11.0.0" }, "devDependencies": { "ava": "^0.25.0", @@ -47,9 +47,9 @@ "eslint-plugin-promise": "^3.5.0", "eslint-plugin-standard": "^3.0.0", "mz": "^2.6.0", - "nyc": "^11.0.0", + "nyc": "^13.0.1", "pkg-up": "^2.0.0", - "sinon": "^5.0.7", + "sinon": "^7.0.0", "tempy": "^0.2.1" }, "engines": { From 8ea94dbcf57b0a9174debe0a381a5a9827726f49 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 13 Sep 2018 00:24:02 -0700 Subject: [PATCH 3/3] Upgrade to ESLint 5 --- common.js | 4 ++-- mac.js | 2 +- package.json | 12 ++++++------ platform.js | 2 +- targets.js | 2 +- test/_setup.js | 4 ++-- test/asar.js | 4 ++-- test/basic.js | 2 +- test/cli.js | 4 ++-- test/darwin.js | 34 +++++++++++++++++----------------- test/ignore.js | 4 ++-- test/infer.js | 6 +++--- test/targets.js | 30 +++++++++++++++--------------- test/win32.js | 6 +++--- win32.js | 2 +- 15 files changed, 59 insertions(+), 59 deletions(-) diff --git a/common.js b/common.js index d389ffa1..7c9bdb5c 100644 --- a/common.js +++ b/common.js @@ -35,7 +35,7 @@ function parseCLIArgs (argv) { if (protocolSchemes && protocolNames && protocolNames.length === protocolSchemes.length) { args.protocols = protocolSchemes.map(function (scheme, i) { - return {schemes: [scheme], name: protocolNames[i]} + return { schemes: [scheme], name: protocolNames[i] } }) } @@ -68,7 +68,7 @@ function parseCLIArgs (argv) { } function sanitizeAppName (name) { - return sanitize(name, {replacement: '-'}) + return sanitize(name, { replacement: '-' }) } function generateFinalBasename (opts) { diff --git a/mac.js b/mac.js index d12d1891..e8333a68 100644 --- a/mac.js +++ b/mac.js @@ -324,7 +324,7 @@ function filterCFBundleIdentifier (identifier) { function createSignOpts (properties, platform, app, version, quiet) { // use default sign opts if osx-sign is true, otherwise clone osx-sign object - let signOpts = properties === true ? {identity: null} : Object.assign({}, properties) + let signOpts = properties === true ? { identity: null } : Object.assign({}, properties) // osx-sign options are handed off to sign module, but // with a few additions from the main options diff --git a/package.json b/package.json index b63c0bb0..9fe0860b 100644 --- a/package.json +++ b/package.json @@ -39,13 +39,13 @@ "ava": "^0.25.0", "buffer-equal": "^1.0.0", "codecov": "^3.0.0", - "eslint": "^4.18.0", - "eslint-config-standard": "^11.0.0", - "eslint-plugin-ava": "^4.3.0", + "eslint": "^5.5.0", + "eslint-config-standard": "^12.0.0", + "eslint-plugin-ava": "^5.1.1", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-node": "^6.0.0", - "eslint-plugin-promise": "^3.5.0", - "eslint-plugin-standard": "^3.0.0", + "eslint-plugin-node": "^7.0.1", + "eslint-plugin-promise": "^4.0.1", + "eslint-plugin-standard": "^4.0.0", "mz": "^2.6.0", "nyc": "^13.0.1", "pkg-up": "^2.0.0", diff --git a/platform.js b/platform.js index fa0f4d99..c66fd219 100644 --- a/platform.js +++ b/platform.js @@ -192,7 +192,7 @@ class App { } debug(`Copying asar: ${src} to ${this.appAsarPath}`) - return fs.copy(src, this.appAsarPath, {overwrite: false, errorOnExist: true}) + return fs.copy(src, this.appAsarPath, { overwrite: false, errorOnExist: true }) }) } diff --git a/targets.js b/targets.js index cfb4a13e..5c0e060f 100644 --- a/targets.js +++ b/targets.js @@ -86,7 +86,7 @@ module.exports = { const archs = officialPlatformArchCombos[platform] if (platform === 'linux') { const excludedArchs = Object.keys(linuxArchBuildVersions) - .filter(arch => !officialLinuxBuildExists({electronVersion: electronVersion}, linuxArchBuildVersions[arch])) + .filter(arch => !officialLinuxBuildExists({ electronVersion: electronVersion }, linuxArchBuildVersions[arch])) return archs.filter(arch => !excludedArchs.includes(arch)) } diff --git a/test/_setup.js b/test/_setup.js index 52db8960..3058b5a2 100644 --- a/test/_setup.js +++ b/test/_setup.js @@ -23,7 +23,7 @@ function skipDownloadingMacZips (platform, arch) { function downloadAll (version) { console.log(`Calling electron-download for ${version} before running tests...`) - const combinations = download.createDownloadCombos({electronVersion: config.version, all: true}, targets.officialPlatforms, targets.officialArchs, skipDownloadingMacZips) + const combinations = download.createDownloadCombos({ electronVersion: config.version, all: true }, targets.officialPlatforms, targets.officialArchs, skipDownloadingMacZips) return Promise.all(combinations.map(combination => downloadElectronZip(version, combination))) } @@ -67,7 +67,7 @@ function npmInstallForFixture (fixture) { return true } else { console.log(`Running npm install in fixtures/${fixture}...`) - return exec('npm install --no-bin-links', {cwd: fixtureDir}) + return exec('npm install --no-bin-links', { cwd: fixtureDir }) } }) } diff --git a/test/asar.js b/test/asar.js index 2830e9d2..a8e94d5e 100644 --- a/test/asar.js +++ b/test/asar.js @@ -12,11 +12,11 @@ test('asar argument test: asar is not set', t => { }) test('asar argument test: asar is true', t => { - t.deepEqual(common.createAsarOpts({asar: true}), {}) + t.deepEqual(common.createAsarOpts({ asar: true }), {}) }) test('asar argument test: asar is not an Object or a bool', t => { - t.false(common.createAsarOpts({asar: 'string'}), 'createAsarOpts returns false') + t.false(common.createAsarOpts({ asar: 'string' }), 'createAsarOpts returns false') }) util.testSinglePlatform('default_app.asar removal test', (t, opts) => { diff --git a/test/basic.js b/test/basic.js index d4602184..0241d51d 100644 --- a/test/basic.js +++ b/test/basic.js @@ -47,7 +47,7 @@ test('download argument test: download.{arch,platform,version} does not overwrit } const downloadOpts = download.createDownloadOpts(opts, 'linux', 'x64') - t.deepEqual(downloadOpts, {arch: 'x64', platform: 'linux', version: '0.36.0'}) + t.deepEqual(downloadOpts, { arch: 'x64', platform: 'linux', version: '0.36.0' }) }) test('sanitize app name for use in file/directory names', t => { diff --git a/test/cli.js b/test/cli.js index f249be8f..e7c03200 100644 --- a/test/cli.js +++ b/test/cli.js @@ -54,7 +54,7 @@ test('CLI argument test: --out without a value is the same as not passing --out' 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'}]) + t.deepEqual(args.protocols, [{ schemes: ['foo'], name: 'Foo' }]) }) test('CLI argument test: --protocol without a corresponding --protocol-name', t => { @@ -64,5 +64,5 @@ test('CLI argument test: --protocol without a corresponding --protocol-name', t 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'}]) + t.deepEqual(args.protocols, [{ schemes: ['foo'], name: 'Foo' }, { schemes: ['bar'], name: 'Bar' }]) }) diff --git a/test/darwin.js b/test/darwin.js index 02517bd6..3d36d6f4 100644 --- a/test/darwin.js +++ b/test/darwin.js @@ -222,7 +222,7 @@ function appHelpersBundleTest (t, opts, helperBundleId, appBundleId) { if (!(process.env.CI && process.platform === 'win32')) { darwinTest('helper app paths test', helperAppPathsTest) - darwinTest('helper app paths test with app name needing sanitization', helperAppPathsTest, {name: '@username/package-name'}, '@username-package-name') + darwinTest('helper app paths test with app name needing sanitization', helperAppPathsTest, { name: '@username/package-name' }, '@username-package-name') const iconBase = path.join(__dirname, 'fixtures', 'monochrome') const icnsPath = `${iconBase}.icns` @@ -267,41 +267,41 @@ if (!(process.env.CI && process.platform === 'win32')) { test('osxSign argument test: default args', t => { const args = true const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version') - t.deepEqual(signOpts, {identity: null, app: 'out', platform: 'darwin', version: 'version'}) + t.deepEqual(signOpts, { identity: null, app: 'out', platform: 'darwin', version: 'version' }) }) test('osxSign argument test: identity=true sets autodiscovery mode', t => { - const args = {identity: true} + const args = { identity: true } const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version') - t.deepEqual(signOpts, {identity: null, app: 'out', platform: 'darwin', version: 'version'}) + t.deepEqual(signOpts, { identity: null, app: 'out', platform: 'darwin', version: 'version' }) }) test('osxSign argument test: entitlements passed to electron-osx-sign', t => { - const args = {entitlements: 'path-to-entitlements'} + const args = { entitlements: 'path-to-entitlements' } const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version') - t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version', entitlements: args.entitlements}) + t.deepEqual(signOpts, { app: 'out', platform: 'darwin', version: 'version', entitlements: args.entitlements }) }) test('osxSign argument test: app not overwritten', t => { - const args = {app: 'some-other-path'} + const args = { app: 'some-other-path' } const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version') - t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'}) + t.deepEqual(signOpts, { app: 'out', platform: 'darwin', version: 'version' }) }) test('osxSign argument test: platform not overwritten', t => { - const args = {platform: 'mas'} + const args = { platform: 'mas' } const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version') - t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'}) + t.deepEqual(signOpts, { app: 'out', platform: 'darwin', version: 'version' }) }) test('osxSign argument test: binaries not set', t => { - const args = {binaries: ['binary1', 'binary2']} + const args = { binaries: ['binary1', 'binary2'] } const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version') - t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'}) + t.deepEqual(signOpts, { app: 'out', platform: 'darwin', version: 'version' }) }) darwinTest('codesign test', (t, opts) => { - opts.osxSign = {identity: 'Developer CodeCert'} + opts.osxSign = { identity: 'Developer CodeCert' } let appPath @@ -325,8 +325,8 @@ if (!(process.env.CI && process.platform === 'win32')) { }) darwinTest('binary naming test', binaryNameTest) - darwinTest('sanitized binary naming test', binaryNameTest, {name: '@username/package-name'}, '@username-package-name') - darwinTest('executableName test', binaryNameTest, {executableName: 'app-name', name: 'MyAppName'}, 'app-name', 'MyAppName') + darwinTest('sanitized binary naming test', binaryNameTest, { name: '@username/package-name' }, '@username-package-name') + darwinTest('executableName test', binaryNameTest, { executableName: 'app-name', name: 'MyAppName' }, 'app-name', 'MyAppName') darwinTest('CFBundleName is the sanitized app name and CFBundleDisplayName is the non-sanitized app name', (t, opts) => { const appBundleIdentifier = 'com.electron.username-package-name' @@ -402,14 +402,14 @@ if (!(process.env.CI && process.platform === 'win32')) { darwinTest('appCopyright/NSHumanReadableCopyright test', (t, baseOpts) => { const copyright = 'Copyright © 2003–2015 Organization. All rights reserved.' - const opts = Object.assign({}, baseOpts, {appCopyright: copyright}) + const opts = Object.assign({}, baseOpts, { appCopyright: copyright }) return packageAndParseInfoPlist(t, opts) .then(info => t.is(info.NSHumanReadableCopyright, copyright, 'NSHumanReadableCopyright should reflect opts.appCopyright')) }) darwinTest('app named Electron packaged successfully', (t, baseOpts) => { - const opts = Object.assign({}, baseOpts, {name: 'Electron'}) + const opts = Object.assign({}, baseOpts, { name: 'Electron' }) let appPath return packager(opts) diff --git a/test/ignore.js b/test/ignore.js index c4e24499..6798fdd3 100644 --- a/test/ignore.js +++ b/test/ignore.js @@ -60,7 +60,7 @@ function ignoreImplicitOutDirTest (t, opts) { test('generateIgnores ignores the generated temporary directory only on Linux', t => { const tmpdir = '/foo/bar' const expected = path.join(tmpdir, 'electron-packager') - let opts = {tmpdir} + let opts = { tmpdir } ignore.generateIgnores(opts) @@ -72,7 +72,7 @@ test('generateIgnores ignores the generated temporary directory only on Linux', }) test('generateOutIgnores ignores all possible platform/arch permutations', (t) => { - const ignores = ignore.generateOutIgnores({name: 'test'}) + const ignores = ignore.generateOutIgnores({ name: 'test' }) t.is(ignores.length, util.allPlatformArchCombosCount) }) diff --git a/test/infer.js b/test/infer.js index 93e57789..b0a636ea 100644 --- a/test/infer.js +++ b/test/infer.js @@ -88,12 +88,12 @@ util.testSinglePlatformParallel('infer using `electron-prebuilt-compile` package util.testSinglePlatformParallel('infer using `electron` package only', inferMissingVersionTest) util.testSinglePlatformParallel('infer where `electron` version is preferred over `electron-prebuilt`', inferElectronVersionTest, 'basic-renamed-to-electron', 'electron') util.testSinglePlatformParallel('infer win32metadata', (t, opts) => { - const expected = {CompanyName: 'Foo Bar'} + const expected = { CompanyName: 'Foo Bar' } return testInferWin32metadata(t, opts, expected, 'win32metadata matches package.json values') }) util.testSinglePlatformParallel('do not infer win32metadata if it already exists', (t, opts) => { - opts.win32metadata = {CompanyName: 'Existing'} + opts.win32metadata = { CompanyName: 'Existing' } const expected = Object.assign({}, opts.win32metadata) return testInferWin32metadata(t, opts, expected, 'win32metadata did not update with package.json values') @@ -103,7 +103,7 @@ util.testSinglePlatformParallel('infer win32metadata when author is an object', name: 'Foo Bar Object', email: 'foobar@example.com' } - const expected = {CompanyName: 'Foo Bar Object'} + const expected = { CompanyName: 'Foo Bar Object' } return testInferWin32metadataAuthorObject(t, opts, author, expected, 'win32metadata did not update with package.json values') }) diff --git a/test/targets.js b/test/targets.js index e78f9faa..2817030b 100644 --- a/test/targets.js +++ b/test/targets.js @@ -26,7 +26,7 @@ function testMultiTarget (testcaseDescription, extraOpts, expectedPackageCount, } function testCombinations (testcaseDescription, arch, platform) { - testMultiTarget(testcaseDescription, {arch: arch, platform: platform}, 4, + testMultiTarget(testcaseDescription, { arch: arch, platform: platform }, 4, 'Packages should be generated for all combinations of specified archs and platforms') } @@ -54,30 +54,30 @@ test('allOfficialArchsForPlatformAndVersion returns mips64el when the correct ve test('validateListFromOptions does not take non-Array/String values', t => { targets.supported.digits = new Set(['64', '65']) - t.false(targets.validateListFromOptions({digits: 64}, 'digits') instanceof Array, + t.false(targets.validateListFromOptions({ digits: 64 }, 'digits') instanceof Array, 'should not be an Array') delete targets.supported.digits }) test('validateListFromOptions works for armv7l host and target arch', t => { sinon.stub(process, 'arch').value('arm') - sinon.stub(process, 'config').value({variables: {arm_version: '7'}}) + sinon.stub(process, 'config').value({ variables: { arm_version: '7' } }) t.deepEqual(targets.validateListFromOptions({}, 'arch'), ['armv7l']) sinon.restore() }) -testMultiTarget('build for all available official targets', {all: true, electronVersion: '1.8.2'}, +testMultiTarget('build for all available official targets', { all: true, electronVersion: '1.8.2' }, util.allPlatformArchCombosCount, 'Packages should be generated for all possible platforms') testMultiTarget('build for all available official targets for a version without arm64 or mips64el support', - {all: true}, + { all: true }, util.allPlatformArchCombosCount - 2, 'Packages should be generated for all possible platforms (except arm64 and mips64el)') -testMultiTarget('platform=all (one arch)', {arch: 'ia32', platform: 'all'}, 2, +testMultiTarget('platform=all (one arch)', { arch: 'ia32', platform: 'all' }, 2, 'Packages should be generated for both 32-bit platforms') -testMultiTarget('arch=all test (one platform)', {arch: 'all', platform: 'linux'}, 3, +testMultiTarget('arch=all test (one platform)', { arch: 'all', platform: 'linux' }, 3, 'Packages should be generated for all expected architectures') testCombinations('multi-platform / multi-arch test, from arrays', ['ia32', 'x64'], ['linux', 'win32']) @@ -93,13 +93,13 @@ test('fails with invalid platform', util.invalidOptionTest({ platform: 'dos' })) -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') -testMultiTarget('platform=linux and arch=mips64el with a supported official Electron version', {arch: 'mips64el', platform: 'linux', electronVersion: '1.8.2-beta.5'}, 1, 'Package should be generated for mips64el') -testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version', {arch: 'mips64el', platform: 'linux'}, 0, 'Package should not be generated for mips64el') -testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version (2.0.0)', {arch: 'mips64el', platform: 'linux', electronVersion: '2.0.0'}, 0, 'Package should not be generated for mips64el') -testMultiTarget('unofficial arch', {arch: 'z80', platform: 'linux', download: {mirror: 'mirror'}}, 1, +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') +testMultiTarget('platform=linux and arch=mips64el with a supported official Electron version', { arch: 'mips64el', platform: 'linux', electronVersion: '1.8.2-beta.5' }, 1, 'Package should be generated for mips64el') +testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version', { arch: 'mips64el', platform: 'linux' }, 0, 'Package should not be generated for mips64el') +testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version (2.0.0)', { arch: 'mips64el', platform: 'linux', electronVersion: '2.0.0' }, 0, 'Package should not be generated for mips64el') +testMultiTarget('unofficial arch', { arch: 'z80', platform: 'linux', download: { mirror: 'mirror' } }, 1, 'Package should be generated for non-standard arch from non-official mirror') -testMultiTarget('unofficial platform', {arch: 'ia32', platform: 'minix', download: {mirror: 'mirror'}}, 1, +testMultiTarget('unofficial platform', { arch: 'ia32', platform: 'minix', download: { mirror: 'mirror' } }, 1, 'Package should be generated for non-standard platform from non-official mirror') diff --git a/test/win32.js b/test/win32.js index 45fa6984..f54e6255 100644 --- a/test/win32.js +++ b/test/win32.js @@ -72,7 +72,7 @@ function setCopyrightTest (appCopyright) { appCopyright: appCopyright } - return generateVersionStringTest('version-string', opts, {LegalCopyright: appCopyright}, 'Legal copyright should match app copyright') + return generateVersionStringTest('version-string', opts, { LegalCopyright: appCopyright }, 'Legal copyright should match app copyright') } function setCopyrightAndCompanyNameTest (appCopyright, companyName) { @@ -86,7 +86,7 @@ function setCopyrightAndCompanyNameTest (appCopyright, companyName) { return generateVersionStringTest( 'version-string', opts, - {LegalCopyright: appCopyright, CompanyName: companyName}, + { LegalCopyright: appCopyright, CompanyName: companyName }, 'Legal copyright should match app copyright and Company name should match win32metadata value' ) } @@ -130,7 +130,7 @@ function setCompanyNameTest (companyName) { return generateVersionStringTest('version-string', opts, - {CompanyName: companyName}, + { CompanyName: companyName }, `Company name should match win32metadata value`) } diff --git a/win32.js b/win32.js index bf6b33d7..1d7fd54e 100644 --- a/win32.js +++ b/win32.js @@ -40,7 +40,7 @@ class WindowsApp extends App { ProductName: this.opts.name }, this.opts.win32metadata) - let rcOpts = {'version-string': win32metadata} + let rcOpts = { 'version-string': win32metadata } if (this.opts.appVersion) { rcOpts['product-version'] = rcOpts['file-version'] = this.opts.appVersion