2015-03-23 02:51:19 +00:00
|
|
|
var os = require('os')
|
|
|
|
var path = require('path')
|
|
|
|
|
|
|
|
module.exports = function packager (opts, cb) {
|
2015-04-27 19:09:24 +00:00
|
|
|
var electronPath
|
2015-05-03 22:16:33 +00:00
|
|
|
var platform
|
2015-04-05 16:04:24 +00:00
|
|
|
|
2015-04-04 16:47:01 +00:00
|
|
|
try {
|
2015-04-27 19:09:24 +00:00
|
|
|
electronPath = require.resolve('electron-prebuilt')
|
|
|
|
electronPath = path.join(electronPath, '..')
|
2015-04-04 16:47:01 +00:00
|
|
|
} catch (e) {
|
2015-04-05 16:04:24 +00:00
|
|
|
try {
|
2015-04-27 19:09:24 +00:00
|
|
|
electronPath = require.resolve(path.join(process.execPath, '../../lib/node_modules/electron-prebuilt'))
|
|
|
|
electronPath = path.join(electronPath, '..')
|
2015-04-05 16:04:24 +00:00
|
|
|
} catch (e) {
|
2015-04-27 19:09:24 +00:00
|
|
|
cb(new Error('Cannot find electron-prebuilt from here, please install it from npm'))
|
2015-04-05 16:04:24 +00:00
|
|
|
}
|
2015-03-23 02:51:19 +00:00
|
|
|
}
|
2015-04-04 16:47:01 +00:00
|
|
|
|
2015-04-27 19:09:24 +00:00
|
|
|
var electronPkg = require(path.join(electronPath, 'package.json'))
|
|
|
|
console.error('Using electron-prebuilt version', electronPkg.version, 'from', electronPath)
|
2015-04-04 16:47:01 +00:00
|
|
|
|
2015-05-03 22:16:33 +00:00
|
|
|
switch (os.platform()) {
|
|
|
|
case 'darwin': platform = require('./mac'); break
|
2015-05-05 04:11:53 +00:00
|
|
|
case 'linux': platform = require('./linux'); break
|
2015-05-06 19:11:03 +00:00
|
|
|
case 'win32': platform = require('./windows'); break
|
2015-05-03 22:16:33 +00:00
|
|
|
default: cb(new Error('Unsupported platform'))
|
2015-03-23 02:51:19 +00:00
|
|
|
}
|
2015-04-24 12:07:39 +00:00
|
|
|
|
2015-05-03 22:16:33 +00:00
|
|
|
platform.createApp(opts, cb, electronPath)
|
2015-03-23 02:51:19 +00:00
|
|
|
}
|