Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Copy Markdown
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
Copy Markdown
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)
}