Skip to content
Open
Changes from all commits
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
30 changes: 27 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ export default function interactive () {
}
}

function getPackageVersion () {
try {
const pkg = require(path.join(process.cwd(), 'package.json'))
return pkg.version
} catch (e) {
return '0.0.1'
}
}

function getElectronVersion () {
try {
const pkg = require(path.join(process.cwd(), 'package.json'))
let fin
if(pkg.dependencies && pkg.dependencies.electron) fin = pkg.dependencies.electron
if(pkg.devDependencies && pkg.devDependencies.electron) fin = pkg.devDependencies.electron
return fin
} catch (e) {
return '7.1.5'
}
}

function runElectronPackager (settings) {
log.log('Electron packager settings:')
log.log(settings)
Expand All @@ -35,7 +56,9 @@ export default function interactive () {
name: getPackageName(),
platform: 'all',
arch: 'all',
electronVersion: '1.6.15',
electronVersion: getElectronVersion(),
version: getPackageVersion(),
defaultIcon: path.join(process.cwd(), 'assets', 'icon.ico'),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the path I use for my icons. You may remove this if you wish.

out: path.join(process.cwd(), 'releases'),
'appBundleId': '',
'appVersion': '',
Expand Down Expand Up @@ -91,12 +114,13 @@ export default function interactive () {
type: 'input',
name: 'appVersion',
message: 'Select App Version(optional):',
default: '0.0.1'
default: settings.version
},
{
type: 'input',
name: 'icon',
message: 'Select Electron icon file:'
message: 'Select Electron icon file:',
default: settings.defaultIcon
},
{
type: 'input',
Expand Down