Nativefier/src/options.js

62 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-01-18 15:07:22 +01:00
import os from 'os';
import path from 'path';
const TEMPLATE_APP_DIR = path.join(__dirname, '../', 'app');
const ELECTRON_VERSION = '0.36.4';
function optionsFactory(name = 'MyApp',
targetUrl = 'http://google.com',
platform = detectPlatform(),
2016-01-18 16:38:52 +01:00
arch = detectArch(),
2016-01-18 15:07:22 +01:00
version = ELECTRON_VERSION,
2016-01-18 16:38:52 +01:00
outDir = process.cwd(),
2016-01-18 15:07:22 +01:00
overwrite = true,
2016-01-18 16:38:52 +01:00
conceal = false,
icon,
2016-01-18 15:07:22 +01:00
badge = false,
width = 1280,
height = 800) {
return {
dir: TEMPLATE_APP_DIR,
name: name,
targetUrl: targetUrl,
platform: platform,
2016-01-18 16:38:52 +01:00
arch: arch,
2016-01-18 15:07:22 +01:00
version: version,
out: outDir,
// optionals
overwrite: overwrite,
asar: conceal,
2016-01-18 16:38:52 +01:00
icon: icon,
2016-01-18 15:07:22 +01:00
// app configuration
badge: badge,
width: width,
height: height
}
}
function detectPlatform() {
const platform = os.platform();
if (platform === 'darwin' || platform === 'win32' || platform === 'linux') {
return platform;
}
console.warn(`Warning: Untested platform ${platform} detected, assuming linux`);
return 'linux';
}
function detectArch() {
const arch = os.arch();
if (arch !== 'ia32' && arch !== 'x64') {
throw `Incompatible architecture ${arch} detected`;
}
return os.arch();
}
export default optionsFactory;