Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Electron dependencies for 3.x/4.x #159

Merged
merged 4 commits into from
Dec 10, 2018
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
21 changes: 19 additions & 2 deletions src/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ const fs = require('fs-extra')
const path = require('path')
const semver = require('semver')

/**
* Determine whether GConf is a necessary dependency, given the Electron version.
*/
function getGConfDepends (version) {
return semver.lt(version, '3.0.0-beta.1') ? ['libgconf2-4'] : []
}

/**
* Determine the GTK dependency based on the Electron version in use.
*/
Expand All @@ -25,28 +32,38 @@ function getTrashDepends (version) {
}
}

/**
* Determine whether libuuid1 is necessary, given the Electron version.
*/
function getUUIDDepends (version) {
return semver.gte(version, '4.0.0-beta.1') ? ['libuuid1'] : []
}

module.exports = {
getElectronVersion: function getElectronVersion (options) {
return fs.readFile(path.resolve(options.src, 'version'))
// The content of the version file pre-4.0 is the tag name, e.g. "v1.8.1"
// The content of the version file post-4.0 is just the version
.then(tag => tag.toString().trim())
},
getGConfDepends: getGConfDepends,
getGTKDepends: getGTKDepends,
getTrashDepends: getTrashDepends,
getUUIDDepends: getUUIDDepends,

/**
* Determine the default dependencies for an Electron application.
*/
getDepends: function getDepends (version) {
return [
getTrashDepends(version),
'libgconf2-4',
getGTKDepends(version),
'libnotify4',
'libnss3',
'libxss1',
'libxtst6',
'xdg-utils'
fcastilloec marked this conversation as resolved.
Show resolved Hide resolved
]
].concat(getGConfDepends(version))
.concat(getUUIDDepends(version))
}
}
22 changes: 22 additions & 0 deletions test/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ describe('dependencies', () => {
})
})

describe('getGConfDepends', () => {
it('returns gconf pre-3.0', () => {
chai.expect(dependencies.getGConfDepends('v2.0.0')).to.deep.equal(['libgconf2-4'])
})

it('returns nothing as of 3.0', () => {
// eslint-disable-next-line no-unused-expressions
chai.expect(dependencies.getGConfDepends('4.0.0')).to.be.an('array').that.is.empty
})
})

describe('getTrashDepends', () => {
it('only depends on gvfs-bin before 1.4.1', () => {
const trashDepends = dependencies.getTrashDepends('v1.3.0')
Expand All @@ -36,4 +47,15 @@ describe('dependencies', () => {
chai.expect(trashDepends).to.match(/libglib2\.0-bin/)
})
})

describe('getUUIDDepends', () => {
it('returns nothing pre-4.0', () => {
// eslint-disable-next-line no-unused-expressions
chai.expect(dependencies.getUUIDDepends('v3.0.0')).to.be.an('array').that.is.empty
})

it('returns uuid as of 4.0', () => {
chai.expect(dependencies.getUUIDDepends('4.0.0')).to.deep.equal(['libuuid1'])
})
})
})