2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-15 17:27:08 +00:00
nativefier/index.js

32 lines
1014 B
JavaScript
Raw Normal View History

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
var platform
2015-04-05 16:04:24 +00:00
try {
2015-04-27 19:09:24 +00:00
electronPath = require.resolve('electron-prebuilt')
electronPath = path.join(electronPath, '..')
} 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-27 19:09:24 +00:00
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
2015-05-06 19:11:03 +00:00
case 'win32': platform = require('./windows'); break
default: cb(new Error('Unsupported platform'))
2015-03-23 02:51:19 +00:00
}
2015-04-24 12:07:39 +00:00
platform.createApp(opts, cb, electronPath)
2015-03-23 02:51:19 +00:00
}