-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref/ Electron packager in external file
- Loading branch information
1 parent
d77cbf1
commit 17b04e8
Showing
2 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"use strict"; | ||
|
||
var packager = require('electron-packager'); | ||
const pkg = require('./package.json'); | ||
const argv = require('minimist')(process.argv.slice(1)); | ||
|
||
const appName = argv.name || pkg.name; | ||
const buildVersion = pkg.version || '1.0'; | ||
const shouldUseAsar = argv.asar || false; | ||
const shouldBuildAll = argv.all || false; | ||
const arch = argv.arch || 'all'; | ||
const platform = argv.platform || 'darwin'; | ||
|
||
const DEFAULT_OPTS = { | ||
dir: './dist', | ||
name: appName, | ||
asar: shouldUseAsar, | ||
buildVersion: buildVersion | ||
}; | ||
|
||
const icon = 'assets/favicon'; | ||
|
||
if (icon) { | ||
DEFAULT_OPTS.icon = icon; | ||
} | ||
|
||
pack(platform, arch, function done(err, appPath) { | ||
if(err) { | ||
console.log(err); | ||
} else { | ||
console.log('Application packaged successfuly!', appPath); | ||
} | ||
|
||
}); | ||
|
||
function pack(plat, arch, cb) { | ||
// there is no darwin ia32 electron | ||
if (plat === 'darwin' && arch === 'ia32') return; | ||
|
||
const iconObj = { | ||
icon: DEFAULT_OPTS.icon + (() => { | ||
|
||
let extension = '.png'; | ||
if (plat === 'darwin') { | ||
extension = '.icns'; | ||
} else if (plat === 'win32') { | ||
extension = '.ico'; | ||
} | ||
return extension; | ||
})() | ||
}; | ||
|
||
const opts = Object.assign({}, DEFAULT_OPTS, { | ||
platform: plat, | ||
arch, | ||
prune: true, | ||
overwrite: true, | ||
all: shouldBuildAll, | ||
out: `app-builds` | ||
}); | ||
|
||
console.log(opts) | ||
packager(opts, cb); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters