Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] }
})
}

Expand Down Expand Up @@ -68,7 +68,7 @@ function parseCLIArgs (argv) {
}

function sanitizeAppName (name) {
return sanitize(name, {replacement: '-'})
return sanitize(name, { replacement: '-' })
}

function generateFinalBasename (opts) {
Expand Down
6 changes: 3 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
// ...
Expand Down Expand Up @@ -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({
// ...
Expand Down Expand Up @@ -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({
// ...
Expand Down
4 changes: 2 additions & 2 deletions ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions infer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
}

Expand Down
8 changes: 4 additions & 4 deletions mac.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,42 @@
"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": "^5.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",
"plist": "^2.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",
"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": "^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": {
"node": ">= 4.0"
"node": ">= 6.0"
},
"scripts": {
"codecov": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
Expand Down
2 changes: 1 addition & 1 deletion platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
})
}

Expand Down
6 changes: 2 additions & 4 deletions prune.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -86,8 +86,8 @@ module.exports = {
const archs = officialPlatformArchCombos[platform]
if (platform === 'linux') {
const excludedArchs = Object.keys(linuxArchBuildVersions)
.filter(arch => !officialLinuxBuildExists({electronVersion: electronVersion}, linuxArchBuildVersions[arch]))
return archs.filter(arch => excludedArchs.indexOf(arch) === -1)
.filter(arch => !officialLinuxBuildExists({ electronVersion: electronVersion }, linuxArchBuildVersions[arch]))
return archs.filter(arch => !excludedArchs.includes(arch))
}

return archs
Expand Down
6 changes: 3 additions & 3 deletions test/_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)))
}
Expand Down Expand Up @@ -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 })
}
})
}
Expand Down
8 changes: 2 additions & 6 deletions test/_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/asar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
6 changes: 1 addition & 5 deletions test/ci/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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' }])
})
Loading