enable os x file drop, add osx torrent file icon

- fixes #131
- partially addresses #77 for osx (now handles .torrent files)
This commit is contained in:
Nate Goldman
2016-03-10 21:51:27 -08:00
parent 0199ff957c
commit f4dc0018dd
5 changed files with 33 additions and 1 deletions

View File

@@ -112,7 +112,7 @@ var linux = {
var platform = process.argv[2]
if (platform === '--darwin') {
buildDarwin()
buildDarwin(postDarwinism)
} else if (platform === '--win32') {
buildWin32()
} else if (platform === '--linux') {
@@ -134,6 +134,37 @@ function buildLinux (cb) {
electronPackager(Object.assign({}, all, linux), done.bind(null, cb))
}
function postDarwinism () {
var plist = require('plist')
var contentsPath = path.join.apply(null, [
__dirname,
'..',
'dist',
`${config.APP_NAME}-darwin-x64`,
`${config.APP_NAME}.app`,
'Contents'
])
var resourcesPath = path.join(contentsPath, 'Resources')
var infoPlistPath = path.join(contentsPath, 'Info.plist')
var webTorrentFileIconPath = path.join.apply(null, [
__dirname,
'..',
'static',
'WebTorrentFile.icns'
])
var infoPlist = plist.parse(fs.readFileSync(infoPlistPath).toString())
infoPlist['CFBundleDocumentTypes'] = [{
CFBundleTypeExtensions: [ 'torrent' ],
CFBundleTypeName: 'BitTorrent Document',
CFBundleTypeRole: 'Editor',
CFBundleTypeIconFile: 'WebTorrentFile.icns'
}]
fs.writeFileSync(infoPlistPath, plist.build(infoPlist))
cp.execSync(`cp ${webTorrentFileIconPath} ${resourcesPath}`)
}
function done (cb, err, appPath) {
if (err) console.error(err.message || err)
else console.log('Built ' + appPath)

View File

@@ -31,6 +31,7 @@
"electron-packager": "^5.0.0",
"electron-prebuilt": "0.36.10",
"path-exists": "^2.1.0",
"plist": "^1.2.0",
"rimraf": "^2.5.2",
"standard": "^6.0.5"
},

BIN
static/WebTorrentFile.icns Normal file

Binary file not shown.

BIN
static/WebTorrentFile.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

BIN
static/WebTorrentFile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB