mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-11 15:51:06 +00:00
6634913bb2
Copies both the electron-prebuilt distribution into the app's toplevel dist directory (by default) and the user's app into the correct subdirectory.
31 lines
957 B
JavaScript
31 lines
957 B
JavaScript
var os = require('os')
|
|
var path = require('path')
|
|
|
|
module.exports = function packager (opts, cb) {
|
|
var electronPath
|
|
var platform
|
|
|
|
try {
|
|
electronPath = require.resolve('electron-prebuilt')
|
|
electronPath = path.join(electronPath, '..')
|
|
} catch (e) {
|
|
try {
|
|
electronPath = require.resolve(path.join(process.execPath, '../../lib/node_modules/electron-prebuilt'))
|
|
electronPath = path.join(electronPath, '..')
|
|
} catch (e) {
|
|
cb(new Error('Cannot find electron-prebuilt from here, please install it from npm'))
|
|
}
|
|
}
|
|
|
|
var electronPkg = require(path.join(electronPath, 'package.json'))
|
|
console.error('Using electron-prebuilt version', electronPkg.version, 'from', electronPath)
|
|
|
|
switch (os.platform()) {
|
|
case 'darwin': platform = require('./mac'); break
|
|
case 'linux': platform = require('./linux'); break
|
|
default: cb(new Error('Unsupported platform'))
|
|
}
|
|
|
|
platform.createApp(opts, cb, electronPath)
|
|
}
|