diff --git a/bin/package.js b/bin/package.js index b1e71c97..e9be096b 100755 --- a/bin/package.js +++ b/bin/package.js @@ -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) diff --git a/package.json b/package.json index c33ae3f7..562076e5 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/static/WebTorrentFile.icns b/static/WebTorrentFile.icns new file mode 100644 index 00000000..c3c459e9 Binary files /dev/null and b/static/WebTorrentFile.icns differ diff --git a/static/WebTorrentFile.ico b/static/WebTorrentFile.ico new file mode 100644 index 00000000..76031cf9 Binary files /dev/null and b/static/WebTorrentFile.ico differ diff --git a/static/WebTorrentFile.png b/static/WebTorrentFile.png new file mode 100644 index 00000000..07d7c2b4 Binary files /dev/null and b/static/WebTorrentFile.png differ