Skip to content

Commit

Permalink
Merge pull request #159 from electron-userland/update-electron-deps
Browse files Browse the repository at this point in the history
Update Electron dependencies for 3.x/4.x
  • Loading branch information
fcastilloec authored Dec 10, 2018
2 parents 2950a63 + 243c2ac commit 1d48c3f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
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'
]
].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'])
})
})
})

0 comments on commit 1d48c3f

Please sign in to comment.