2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-10 15:21:03 +00:00

add custom protocol handler support

This commit is contained in:
Mathias Buus 2015-04-04 21:13:27 -07:00
parent 7c9b95fa1b
commit 18871061d5
2 changed files with 18 additions and 0 deletions

9
cli.js
View File

@ -5,6 +5,15 @@ var packager = require('./')
args.dir = args._[0]
args.name = args._[1]
var protocolSchemes = args.protocol
var protocolNames = args['protocol-names']
if (protocolSchemes && protocolNames && protocolNames.length === protocolSchemes.length) {
args.protocol = protocolSchemes.map(function (scheme, i) {
return {schemes: [scheme], name: protocolNames[i]}
})
}
if (!args.dir || !args.name) {
console.error('Usage: atom-shell-packager <sourcedir> <Appname>')
process.exit(1)

View File

@ -57,6 +57,15 @@ module.exports = function packager (opts, cb) {
pl2.CFBundleIdentifier = bundleHelperId
pl2.CFBundleName = opts.name
if (opts.protocols) {
pl2.CFBundleURLTypes = pl1.CFBundleURLTypes = opts.protocols.map(function (protocol) {
return {
CFBundleURLName: protocol.name,
CFBundleURLSchemes: [].concat(protocol.schemes)
}
})
}
fs.writeFileSync(paths.info1, plist.build(pl1))
fs.writeFileSync(paths.info2, plist.build(pl2))