Skip to content

Commit

Permalink
add support for generating deb package
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Oct 9, 2017
1 parent 5b22bc9 commit e380e4e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ addons:
# this package is essential for testing Electron in a headless fashion
# https://github.com/electron/electron/blob/master/docs/tutorial/testing-on-headless-ci.md
- xvfb
# packages required for electron-installer-debian
- fakeroot
- dpkg

branches:
only:
Expand Down Expand Up @@ -52,5 +55,8 @@ script:
- npm run test:setup
- npm test

after_success:
- npm run package

after_failure:
- npm run test:review
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"cross-env": "^5.0.5",
"css-loader": "^0.28.5",
"electron": "1.7.8",
"electron-installer-debian": "^0.5.2",
"electron-mocha": "^4.0.0",
"electron-packager": "^8.7.2",
"electron-winstaller": "2.5.2",
Expand Down
36 changes: 35 additions & 1 deletion script/package
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ const distInfo = require('./dist-info')

const distPath = distInfo.getDistPath()
const productName = distInfo.getProductName()
const outputDir = path.join(distPath, '..', 'installer')

if (process.platform === 'darwin') {
packageOSX()
} else if (process.platform === 'win32') {
packageWindows()
} else if (process.platform === 'linux') {
packageLinux()
} else {
console.error(`I dunno how to package for ${process.platform} :(`)
process.exit(1)
Expand All @@ -31,7 +34,6 @@ function packageOSX() {

function packageWindows() {
const electronInstaller = require('electron-winstaller')
const outputDir = path.join(distPath, '..', 'installer')
const setupCertificatePath = path.join(
__dirname,
'setup-windows-certificate.ps1'
Expand Down Expand Up @@ -110,3 +112,35 @@ function packageWindows() {
process.exit(1)
})
}

function packageDebian() {
const installer = require('electron-installer-debian')

var options = {
src: distPath,
dest: outputDir,
arch: 'amd64',
}

return new Promise((resolve, reject) => {
console.log('Creating .deb package...')
installer(options, function(err) {
if (err) {
reject(err)
} else {
resolve()
}
})
})
}

function packageLinux() {
Promise.all([packageDebian()])
.catch(err => {
console.error(err, err.stack)
process.exit(1)
})
.then(() => {
console.log(`Successfully created packages at ${outputDir}`)
})
}

0 comments on commit e380e4e

Please sign in to comment.