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

add a better packaging script that works on linux #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
},
"devDependencies": {
"electron-packager": "^4.1.2",
"electron-prebuilt": "^0.27.2"
"electron-prebuilt": "0.27.2"
},
"bin": {
"playback": "./app.js"
},
"scripts": {
"start": "electron app.js",
"dev": "electron app.js test.mp4",
"mac-bundle": "electron-packager . Playback --platform=darwin --arch=x64 --version=0.27.2 --ignore=node_modules/electron-prebuilt && cp info.plist Playback.app/Contents/Info.plist && cp icon.icns Playback.app/Contents/Resources/atom.icns",
"win-bundle": "electron-packager . Playback --platform=win32 --arch=ia32 --version=0.27.2 --icon=icon.ico"
"mac-bundle": "node pkg.js darwin x64",
"win-bundle": "node pkg.js win32 ia32",
"bundle": "node pkg.js"
},
"repository": {
"type": "git",
Expand Down
52 changes: 52 additions & 0 deletions pkg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node

// from https://github.com/moose-team/friends/blob/master/pkg.js

var os = require('os')
var pkgjson = require('./package.json')
var path = require('path')
var sh = require('shelljs')

var appVersion = pkgjson.version
var appName = 'Playback'
var electronPackager = './node_modules/.bin/electron-packager'
var electronVersion = pkgjson.devDependencies['electron-prebuilt']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require('electron-prebuilt/package.json').version is more cleaner since we then can use a semver again

var icon = 'icon.icns'

if (process.argv[2] === '--all') {
// build for all platforms
var archs = ['ia32', 'x64']
var platforms = ['linux', 'win32', 'darwin']

platforms.forEach(function (plat) {
archs.forEach(function (arch) {
pack(plat, arch)
})
})
} else if (process.argv[2] && process.argv[3]) {
pack(process.argv[2], process.argv[3])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation is off here

} else {
// build for current platform only
pack(os.platform(), os.arch())
}

function pack (plat, arch) {
var outputPath = path.join('.', 'pkg', appVersion, plat, arch)

sh.exec('./node_modules/.bin/rimraf ' + outputPath)

// there is no darwin ia32 electron
if (plat === 'darwin' && arch === 'ia32') return

var cmd = electronPackager + ' . "' + appName + '"' +
' --platform=' + plat +
' --arch=' + arch +
' --version=' + electronVersion +
' --app-version' + appVersion +
' --icon=' + icon +
' --out=' + outputPath +
' --prune' +
' --ignore=pkg' // ignore the pkg directory or hilarity will ensue
console.log(cmd)
sh.exec(cmd)
}